index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <!-- 修改现货合同-->
  3. <a-modal class="commonModal modify-custom"
  4. title="修改现货合同"
  5. v-if="visible"
  6. v-model:visible="visible"
  7. @cancel="cancel"
  8. width="890px">
  9. <template #footer>
  10. <a-button key="submit"
  11. type="primary"
  12. :loading="loading"
  13. @click="submit">完成</a-button>
  14. </template>
  15. <a-form class="inlineForm"
  16. ref="formRef"
  17. :model="formState"
  18. :rules="rules">
  19. <fieldset class="formFieldSet">
  20. <legend>基本信息</legend>
  21. <a-row :gutter="24">
  22. <a-col :span="12">
  23. <a-form-item label="合同编号"
  24. name="ContractNo">
  25. <a-input class="dialogInput"
  26. style="width: 200px"
  27. v-model:value="formState.ContractNo"
  28. placeholder="请输入合同编号" />
  29. </a-form-item>
  30. </a-col>
  31. <a-col :span="12">
  32. <a-form-item label="合同类型"
  33. name="ContractType">
  34. <a-select class="inlineFormSelect"
  35. style="width: 200px"
  36. @change="contractChange"
  37. v-model:value="formState.ContractType"
  38. placeholder="请选择合同类型">
  39. <a-select-option v-for="item in contractType"
  40. :key="item.key"
  41. :value="item.key">
  42. {{item.value}}
  43. </a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="12">
  48. <a-form-item label="业务类型"
  49. name="BizType">
  50. <a-select class="inlineFormSelect"
  51. style="width: 200px"
  52. v-model:value="formState.BizType"
  53. placeholder="请选择业务类型">
  54. <a-select-option v-for="item in businessType"
  55. :key="item.key"
  56. :value="item.key">
  57. {{item.value}}
  58. </a-select-option>
  59. </a-select>
  60. </a-form-item>
  61. </a-col>
  62. <template v-if="isSell">
  63. <a-col :span="12">
  64. <a-form-item label="采购方"
  65. name="BuyUserID">
  66. <a-select class="inlineFormSelect"
  67. style="width: 200px"
  68. v-model:value="formState.BuyUserID"
  69. placeholder="请选择客户">
  70. <!-- 客户资料列表 正常 -->
  71. <a-select-option :value="i"
  72. v-for="(item, i) in customList"
  73. :key="item.userid">
  74. {{item.customername}}
  75. </a-select-option>
  76. </a-select>
  77. </a-form-item>
  78. </a-col>
  79. <a-col :span="12">
  80. <a-form-item label="销售方">
  81. <span class="white">{{getUserName()}}</span>
  82. </a-form-item>
  83. </a-col>
  84. </template>
  85. <template v-else>
  86. <a-col :span="12">
  87. <a-form-item label="采购方">
  88. <span class="white">{{getUserName()}}</span>
  89. </a-form-item>
  90. </a-col>
  91. <a-col :span="12">
  92. <a-form-item label="销售方"
  93. name="SellUserID">
  94. <a-select class="inlineFormSelect"
  95. v-model:value="formState.SellUserID"
  96. style="width: 200px"
  97. placeholder="请选择客户">
  98. <!-- 客户资料列表 正常 -->
  99. <a-select-option :value="i"
  100. v-for="(item, i) in customList"
  101. :key="item.userid">
  102. {{item.customername}}
  103. </a-select-option>
  104. </a-select>
  105. </a-form-item>
  106. </a-col>
  107. </template>
  108. <a-col :span="12">
  109. <a-form-item label="合同附件"
  110. name="ContractAttachment">
  111. <div class="upload">
  112. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  113. :transform-file="transformFile">
  114. <a-button class="uploadBtn">上传</a-button>
  115. </a-upload>
  116. <div class="look">查看附件</div>
  117. </div>
  118. </a-form-item>
  119. </a-col>
  120. </a-row>
  121. </fieldset>
  122. <fieldset class="formFieldSet">
  123. <legend>现货信息</legend>
  124. <a-row :gutter="24">
  125. <a-col :span="12">
  126. <a-form-item label="现货品种"
  127. name="DeliveryGoodsID">
  128. <a-select class="inlineFormSelect"
  129. style="width: 200px"
  130. @change="deliveryGoodsChange"
  131. v-model:value="formState.DeliveryGoodsID"
  132. placeholder="请选择现货品种">
  133. <a-select-option v-for="item in deliveryGoodsList"
  134. :key="item.deliverygoodsid"
  135. :value="item.deliverygoodsid">
  136. {{item.deliverygoodsname}}
  137. </a-select-option>
  138. </a-select>
  139. </a-form-item>
  140. </a-col>
  141. <a-col :span="12">
  142. <a-form-item label="品类"
  143. name="WrStandardID">
  144. <a-select class="inlineFormSelect"
  145. style="width: 200px"
  146. @change="WrStandardChange"
  147. v-model:value="formState.WrStandardID"
  148. placeholder="请选择品类">
  149. <a-select-option v-for="item in gmlist"
  150. :key="item.wrstandardid"
  151. :value="item.wrstandardid">
  152. {{item.wrstandardname}}
  153. </a-select-option>
  154. </a-select>
  155. </a-form-item>
  156. </a-col>
  157. <a-col :span="12">
  158. <a-form-item label="品牌"
  159. name="SpotGoodsBrandID">
  160. <a-select class="inlineFormSelect"
  161. style="width: 200px"
  162. v-model:value="formState.SpotGoodsBrandID"
  163. placeholder="请选择品牌">
  164. <a-select-option v-for="item in gblist"
  165. :key="item.brandid"
  166. :value="item.brandid">
  167. {{item.brandname}}
  168. </a-select-option>
  169. </a-select>
  170. </a-form-item>
  171. </a-col>
  172. <a-col :span="12">
  173. <a-form-item label="标仓系数"
  174. name="ConvertFactor">
  175. <a-input class="dialogInput"
  176. style="width: 200px"
  177. v-model:value="formState.ConvertFactor"
  178. readonly
  179. placeholder="选择品类后自动填入" />
  180. </a-form-item>
  181. </a-col>
  182. <a-col :span="24">
  183. <a-form-item label="商品规格"
  184. name="SpotGoodsDesc">
  185. <a-input class="dialogInput"
  186. style="width: 200px"
  187. v-model:value="formState.SpotGoodsDesc"
  188. placeholder="请输入商品规格" />
  189. </a-form-item>
  190. </a-col>
  191. </a-row>
  192. </fieldset>
  193. <fieldset class="formFieldSet">
  194. <legend>价格信息</legend>
  195. <a-row :gutter="24">
  196. <a-col :span="12">
  197. <a-form-item label="定价类型"
  198. name="PriceType">
  199. <a-select class="inlineFormSelect"
  200. style="width: 200px"
  201. v-model:value="formState.PriceType"
  202. placeholder="请选择定价类型">
  203. <a-select-option v-for="item in priceType"
  204. :key="item.key"
  205. :value="item.key">
  206. {{item.value}}
  207. </a-select-option>
  208. </a-select>
  209. </a-form-item>
  210. </a-col>
  211. <a-col :span="12">
  212. <a-form-item label="结算币种"
  213. name="CurrencyID">
  214. <a-select class="inlineFormSelect"
  215. v-model:value="formState.CurrencyID"
  216. style="width: 200px"
  217. placeholder="请选择结算币种">
  218. <a-select-option v-for="item in payCurrency"
  219. :key="item.enumdicid"
  220. :value="item.enumdicid">
  221. {{item.enumdicname}}
  222. </a-select-option>
  223. </a-select>
  224. </a-form-item>
  225. </a-col>
  226. <a-col :span="12">
  227. <a-form-item label="数量"
  228. name="Qty">
  229. <a-input class="dialogInput suffixGrey"
  230. v-model:value="formState.Qty"
  231. style="width: 200px"
  232. @change="getAmout"
  233. placeholder="请输入数量"
  234. :suffix="numberUnit" />
  235. </a-form-item>
  236. </a-col>
  237. <a-col :span="12"
  238. v-if="formState.PriceType === 3">
  239. <a-form-item label="暂定价">
  240. <a-input class="dialogInput suffixGrey"
  241. style="width: 200px"
  242. :suffix="payCurrencyUnit"
  243. placeholder="请输入暂定价" />
  244. </a-form-item>
  245. </a-col>
  246. <!-- 以下是点价的价格信息 start -->
  247. <template v-if="formState.PriceType === 2 || formState.PriceType === 3">
  248. <a-col :span="12">
  249. <a-form-item label="点价合约"
  250. name="GoodsID">
  251. <a-select class="inlineFormSelect"
  252. v-model:value="formState.GoodsID"
  253. style="width: 200px"
  254. placeholder="请选择点价合约">
  255. <a-select-option v-for="item in goodsList"
  256. :key="item.goodsid"
  257. :value="item.goodsid">
  258. {{item.goodsname}}
  259. </a-select-option>
  260. </a-select>
  261. </a-form-item>
  262. </a-col>
  263. <a-col :span="12">
  264. <a-form-item label="升贴水"
  265. name="PriceMove">
  266. <a-input class="dialogInput suffixGrey"
  267. v-model:value="formState.PriceMove"
  268. placeholder="请输入升贴水"
  269. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  270. style="width: 200px" />
  271. </a-form-item>
  272. </a-col>
  273. <a-col :span="12">
  274. <a-form-item label="点价期">
  275. <a-range-picker v-model:value="priceDate"
  276. class="commonPicker"
  277. :disabled-date="disabledDate"
  278. style="width: 200px"
  279. :show-time="{hideDisabledOptions: true}"
  280. format="YYYY-MM-DD" />
  281. </a-form-item>
  282. </a-col>
  283. <a-col :span="12">
  284. <a-form-item label="交收期">
  285. <a-range-picker v-model:value="deliveryDate"
  286. class="commonPicker"
  287. style="width: 200px"
  288. :disabled-date="disabledDate"
  289. :show-time="{hideDisabledOptions: true}"
  290. format="YYYY-MM-DD" />
  291. </a-form-item>
  292. </a-col>
  293. </template>
  294. <!-- 以上是点价的价格信息 end -->
  295. <template v-if="formState.PriceType === 1">
  296. <a-col :span="12">
  297. <a-form-item label="价格"
  298. name="Price">
  299. <a-input class="dialogInput suffixGrey"
  300. v-model:value="formState.Price"
  301. @change="getAmout"
  302. placeholder="请输入价格"
  303. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  304. style="width: 200px" />
  305. </a-form-item>
  306. </a-col>
  307. <a-col :span="12">
  308. <a-form-item label="金额"
  309. class="relative"
  310. name="Amount">
  311. <a-input class="dialogInput suffixGrey"
  312. v-model:value="formState.Amount"
  313. readonly
  314. placeholder="输入数量和价格后自动算"
  315. :suffix="payCurrencyUnit"
  316. style="width: 200px" />
  317. </a-form-item>
  318. </a-col>
  319. <a-col :span="24">
  320. <a-form-item label="交收期">
  321. <a-range-picker v-model:value="deliveryDate"
  322. style="width: 200px"
  323. class="commonPicker"
  324. :disabled-date="disabledDate"
  325. :show-time="{hideDisabledOptions: true}"
  326. format="YYYY-MM-DD" />
  327. </a-form-item>
  328. </a-col>
  329. </template>
  330. </a-row>
  331. </fieldset>
  332. <fieldset class="formFieldSet">
  333. <legend>其他信息</legend>
  334. <a-row :gutter="24">
  335. <a-col :span="12">
  336. <a-form-item label="保证金"
  337. name="ContractMargin">
  338. <a-input class="dialogInput suffixGrey"
  339. placeholder="请输入保证金"
  340. v-model:value="formState.ContractMargin"
  341. style="width: 200px"
  342. :suffix="payCurrencyUnit" />
  343. </a-form-item>
  344. </a-col>
  345. <a-col :span="12">
  346. <a-form-item label="业务员"
  347. name="SaleUserID">
  348. <a-select class="inlineFormSelect"
  349. v-model:value="formState.SaleUserID"
  350. style="width: 200px"
  351. placeholder="请选择业务员">
  352. <a-select-option v-for="item in businesserList"
  353. :key="item.id"
  354. :value="item.id">
  355. {{item.name}}
  356. </a-select-option>
  357. </a-select>
  358. </a-form-item>
  359. </a-col>
  360. </a-row>
  361. <a-row :gutter="24">
  362. <a-col :span="12">
  363. <a-form-item label="跟单员"
  364. name="MerUserID">
  365. <a-select class="inlineFormSelect"
  366. v-model:value="formState.MerUserID"
  367. style="width: 200px"
  368. placeholder="请选择跟单员">
  369. <a-select-option v-for="item in merchandiserList"
  370. :key="item.id"
  371. :value="item.id">
  372. {{item.name}}
  373. </a-select-option>
  374. </a-select>
  375. </a-form-item>
  376. </a-col>
  377. <a-col :span="12">
  378. <a-form-item label="交易用户"
  379. name="TradeUserID">
  380. <a-select class="inlineFormSelect"
  381. style="width: 200px"
  382. v-model:value="formState.TradeUserID"
  383. placeholder="请选择期货账户">
  384. <a-select-option v-for="item in traderList"
  385. :key="item.id"
  386. :value="item.id">
  387. {{item.name}}
  388. </a-select-option>
  389. </a-select>
  390. </a-form-item>
  391. </a-col>
  392. </a-row>
  393. <a-row :gutter="24">
  394. <a-col :span="24">
  395. <a-form-item label="备注">
  396. <a-input class="dialogInput"
  397. style="width: 608px"
  398. placeholder="请输入备注" />
  399. </a-form-item>
  400. </a-col>
  401. </a-row>
  402. </fieldset>
  403. </a-form>
  404. </a-modal>
  405. </template>
  406. <script lang="ts">
  407. import { defineComponent, onMounted, PropType, ref, toRaw, watchEffect } from 'vue';
  408. import { closeModal } from '@/common/setup/modal/index';
  409. import { initData } from '@/common/methods';
  410. import { getUserName, getUsrId } from '@/services/bus/user';
  411. import { getGoodsList } from '@/services/bus/goods';
  412. import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
  413. import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
  414. import { FormState } from '../interface';
  415. import { formatTime } from '@/common/methods/format';
  416. import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
  417. import { handleAccountManager } from '../setup';
  418. import { Moment } from 'moment';
  419. import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
  420. interface Obj {
  421. [props: string]: any;
  422. }
  423. export default defineComponent({
  424. name: 'modify-spot-contract',
  425. props: {
  426. selectedRow: {
  427. type: Object as PropType<Ermcp3ContractRsp>,
  428. default: {},
  429. },
  430. },
  431. components: {},
  432. setup(props, context) {
  433. const { visible, cancel } = closeModal('spot_contract_btn_modify');
  434. const loading = ref<boolean>(false);
  435. const { formState, businessType } = handleFromState();
  436. console.log('props.selectedRow', props.selectedRow);
  437. // 表单
  438. const formRef = ref();
  439. const { rules } = handleFormRule(formState);
  440. // 合同类型
  441. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract();
  442. // 处理现货商品
  443. const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
  444. // 价格信息
  445. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  446. // 日期
  447. const { deliveryDate, priceDate, disabledDate } = handleDate();
  448. // 处理金额
  449. const { getAmout } = handleAmout(formState);
  450. // 账号列表: 交易用户 业务员 跟单员
  451. const { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList } = handleAccountManager();
  452. // 现货商品列表
  453. const goodsList = ref<Goods[]>([]);
  454. watchEffect(() => {
  455. // // formState.ContractAttachment = props.selectedRow.attachment
  456. // formState.ContractAttachment = new Uint8Array()
  457. // formState.SpotGoodsBrandID = +props.selectedRow.spotcontractid
  458. if (props.selectedRow.contractno) {
  459. // 处理第一次加载的
  460. const obj: Obj = {};
  461. Object.keys(formState).forEach((el) => {
  462. const key = el.toLocaleLowerCase() as keyof Ermcp3ContractRsp;
  463. if (Reflect.has(props.selectedRow, key)) {
  464. obj[el] = props.selectedRow[key];
  465. } else {
  466. console.warn(`${key}不对应`);
  467. }
  468. });
  469. Object.assign(formState, obj);
  470. props.selectedRow.deliverygoodsid && deliveryGoodsChange(props.selectedRow.deliverygoodsid);
  471. }
  472. });
  473. function submit() {}
  474. initData(() => {
  475. queryCustomList();
  476. getDeliveryGoods();
  477. goodsList.value = getGoodsList();
  478. getRoleList();
  479. getBusinesserList();
  480. });
  481. return {
  482. visible,
  483. cancel,
  484. submit,
  485. formRef,
  486. loading,
  487. maskClosableFlag: false,
  488. formState,
  489. rules,
  490. businessType,
  491. contractType,
  492. isSell,
  493. contractChange,
  494. customList,
  495. deliveryGoodsList,
  496. gblist,
  497. gmlist,
  498. deliveryGoodsChange,
  499. WrStandardChange,
  500. priceType,
  501. payCurrency,
  502. payCurrencyUnit,
  503. parCurrencyChange,
  504. numberUnit,
  505. getUserName,
  506. deliveryDate,
  507. priceDate,
  508. disabledDate,
  509. goodsList,
  510. getAmout,
  511. traderList,
  512. businesserList,
  513. merchandiserList,
  514. };
  515. },
  516. });
  517. </script>
  518. <style lang="less">
  519. .modify-custom {
  520. }
  521. </style
  522. >;