index.vue 22 KB

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