index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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. <UploadImg :visible="visible"
  113. :imgList="uploadImgList"
  114. @upload="uploadImgAction" />
  115. </a-form-item>
  116. </a-col>
  117. </a-row>
  118. </fieldset>
  119. <fieldset class="formFieldSet">
  120. <legend>现货信息</legend>
  121. <a-row :gutter="24">
  122. <a-col :span="12">
  123. <a-form-item label="现货品种"
  124. name="DeliveryGoodsID">
  125. <a-select class="inlineFormSelect"
  126. style="width: 200px"
  127. @change="deliveryGoodsChange"
  128. v-model:value="formState.DeliveryGoodsID"
  129. placeholder="请选择现货品种">
  130. <a-select-option v-for="item in deliveryGoodsList"
  131. :key="item.deliverygoodsid"
  132. :value="item.deliverygoodsid">
  133. {{item.deliverygoodsname}}
  134. </a-select-option>
  135. </a-select>
  136. </a-form-item>
  137. </a-col>
  138. <a-col :span="12">
  139. <a-form-item label="商品"
  140. name="WrStandardID">
  141. <a-select class="inlineFormSelect"
  142. style="width: 200px"
  143. @change="WrStandardChange"
  144. v-model:value="formState.WrStandardID"
  145. placeholder="请选择商品">
  146. <a-select-option v-for="item in gmlist"
  147. :key="item.wrstandardid"
  148. :value="item.wrstandardid">
  149. {{item.wrstandardname}}
  150. </a-select-option>
  151. </a-select>
  152. </a-form-item>
  153. </a-col>
  154. <a-col :span="12">
  155. <a-form-item label="品牌"
  156. name="SpotGoodsBrandID">
  157. <a-select class="inlineFormSelect"
  158. style="width: 200px"
  159. v-model:value="formState.SpotGoodsBrandID"
  160. placeholder="请选择品牌">
  161. <a-select-option v-for="item in gblist"
  162. :key="item.brandid"
  163. :value="item.brandid">
  164. {{item.brandname}}
  165. </a-select-option>
  166. </a-select>
  167. </a-form-item>
  168. </a-col>
  169. <a-col :span="12">
  170. <a-form-item label="标仓系数"
  171. name="ConvertFactor">
  172. <a-input class="dialogInput"
  173. style="width: 200px"
  174. v-model:value="formState.ConvertFactor"
  175. readonly
  176. placeholder="选择商品后自动填入" />
  177. </a-form-item>
  178. </a-col>
  179. <a-col :span="24">
  180. <a-form-item label="商品规格"
  181. name="SpotGoodsDesc">
  182. <a-input class="dialogInput"
  183. style="width: 200px"
  184. v-model:value="formState.SpotGoodsDesc"
  185. placeholder="请输入商品规格" />
  186. </a-form-item>
  187. </a-col>
  188. </a-row>
  189. </fieldset>
  190. <fieldset class="formFieldSet">
  191. <legend>价格信息</legend>
  192. <a-row :gutter="24">
  193. <a-col :span="12">
  194. <a-form-item label="定价类型"
  195. name="PriceType">
  196. <a-select class="inlineFormSelect"
  197. style="width: 200px"
  198. v-model:value="formState.PriceType"
  199. placeholder="请选择定价类型">
  200. <a-select-option v-for="item in priceType"
  201. :key="item.key"
  202. :value="item.key">
  203. {{item.value}}
  204. </a-select-option>
  205. </a-select>
  206. </a-form-item>
  207. </a-col>
  208. <a-col :span="12">
  209. <a-form-item label="结算币种"
  210. name="CurrencyID">
  211. <a-select class="inlineFormSelect"
  212. v-model:value="formState.CurrencyID"
  213. style="width: 200px"
  214. placeholder="请选择结算币种">
  215. <a-select-option v-for="item in payCurrency"
  216. :key="item.enumitemname"
  217. :value="item.enumitemname">
  218. {{item.enumdicname}}
  219. </a-select-option>
  220. </a-select>
  221. </a-form-item>
  222. </a-col>
  223. <a-col :span="12">
  224. <a-form-item label="数量"
  225. name="Qty">
  226. <a-input class="dialogInput suffixGrey"
  227. v-model:value="formState.Qty"
  228. style="width: 200px"
  229. @change="getAmout"
  230. placeholder="请输入数量"
  231. :suffix="numberUnit" />
  232. </a-form-item>
  233. </a-col>
  234. <a-col :span="12"
  235. v-if="formState.PriceType === 3">
  236. <a-form-item label="暂定价">
  237. <a-input class="dialogInput suffixGrey"
  238. style="width: 200px"
  239. :suffix="payCurrencyUnit"
  240. placeholder="请输入暂定价" />
  241. </a-form-item>
  242. </a-col>
  243. <!-- 以下是点价的价格信息 start -->
  244. <template v-if="formState.PriceType === 2 || formState.PriceType === 3">
  245. <a-col :span="12">
  246. <a-form-item label="点价合约"
  247. name="GoodsID">
  248. <a-select class="inlineFormSelect"
  249. v-model:value="formState.GoodsID"
  250. style="width: 200px"
  251. placeholder="请选择点价合约">
  252. <a-select-option v-for="item in goodsList"
  253. :key="item.goodsid"
  254. :value="item.goodsid">
  255. {{item.goodsname}}
  256. </a-select-option>
  257. </a-select>
  258. </a-form-item>
  259. </a-col>
  260. <a-col :span="12">
  261. <a-form-item label="升贴水"
  262. name="PriceMove">
  263. <a-input-number class="dialogInput suffixGrey"
  264. v-model:value="formState.PriceMove"
  265. placeholder="请输入升贴水"
  266. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  267. style="width: 200px" />
  268. </a-form-item>
  269. </a-col>
  270. <a-col :span="12">
  271. <a-form-item label="点价期">
  272. <a-range-picker v-model:value="priceDate"
  273. class="commonPicker"
  274. :disabled-date="disabledDate"
  275. style="width: 200px"
  276. :show-time="{hideDisabledOptions: true}"
  277. format="YYYY-MM-DD" />
  278. </a-form-item>
  279. </a-col>
  280. <a-col :span="12">
  281. <a-form-item label="交收期">
  282. <a-range-picker v-model:value="deliveryDate"
  283. class="commonPicker"
  284. style="width: 200px"
  285. :disabled-date="disabledDate"
  286. :show-time="{hideDisabledOptions: true}"
  287. format="YYYY-MM-DD" />
  288. </a-form-item>
  289. </a-col>
  290. </template>
  291. <!-- 以上是点价的价格信息 end -->
  292. <template v-if="formState.PriceType === 1">
  293. <a-col :span="12">
  294. <a-form-item label="价格"
  295. name="Price">
  296. <a-input class="dialogInput suffixGrey"
  297. v-model:value="formState.Price"
  298. @change="getAmout"
  299. placeholder="请输入价格"
  300. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  301. style="width: 200px" />
  302. </a-form-item>
  303. </a-col>
  304. <a-col :span="12">
  305. <a-form-item label="金额"
  306. class="relative"
  307. name="Amount">
  308. <a-input class="dialogInput suffixGrey"
  309. v-model:value="formState.Amount"
  310. readonly
  311. placeholder="输入数量和价格后自动算"
  312. :suffix="payCurrencyUnit"
  313. style="width: 200px" />
  314. </a-form-item>
  315. </a-col>
  316. <a-col :span="24">
  317. <a-form-item label="交收期">
  318. <a-range-picker v-model:value="deliveryDate"
  319. style="width: 200px"
  320. class="commonPicker"
  321. :disabled-date="disabledDate"
  322. :show-time="{hideDisabledOptions: true}"
  323. format="YYYY-MM-DD" />
  324. </a-form-item>
  325. </a-col>
  326. </template>
  327. </a-row>
  328. </fieldset>
  329. <fieldset class="formFieldSet">
  330. <legend>其他信息</legend>
  331. <a-row :gutter="24">
  332. <a-col :span="12">
  333. <a-form-item label="保证金"
  334. name="ContractMargin">
  335. <a-input class="dialogInput suffixGrey"
  336. placeholder="请输入保证金"
  337. v-model:value="formState.ContractMargin"
  338. style="width: 200px"
  339. :suffix="payCurrencyUnit" />
  340. </a-form-item>
  341. </a-col>
  342. <a-col :span="12">
  343. <a-form-item label="业务员"
  344. name="SaleUserID">
  345. <a-select class="inlineFormSelect"
  346. v-model:value="formState.SaleUserID"
  347. style="width: 200px"
  348. placeholder="请选择业务员">
  349. <a-select-option v-for="item in businesserList"
  350. :key="item.loginid"
  351. :value="item.loginid">
  352. {{item.accountname}}-{{item.logincode}}
  353. </a-select-option>
  354. </a-select>
  355. </a-form-item>
  356. </a-col>
  357. </a-row>
  358. <a-row :gutter="24">
  359. <a-col :span="12">
  360. <a-form-item label="跟单员"
  361. name="MerUserID">
  362. <a-select class="inlineFormSelect"
  363. v-model:value="formState.MerUserID"
  364. style="width: 200px"
  365. placeholder="请选择跟单员">
  366. <a-select-option v-for="item in merchandiserList"
  367. :key="item.loginid"
  368. :value="item.loginid">
  369. {{item.accountname}}-{{item.logincode}}
  370. </a-select-option>
  371. </a-select>
  372. </a-form-item>
  373. </a-col>
  374. <a-col :span="12">
  375. <a-form-item label="交易用户"
  376. name="TradeUserID">
  377. <a-select class="inlineFormSelect"
  378. style="width: 200px"
  379. v-model:value="formState.TradeUserID"
  380. placeholder="请选择期货账户">
  381. <a-select-option v-for="item in traderList"
  382. :key="item.roleid"
  383. :value="item.roleid">
  384. {{item.rolename}}
  385. </a-select-option>
  386. </a-select>
  387. </a-form-item>
  388. </a-col>
  389. </a-row>
  390. <a-row :gutter="24">
  391. <a-col :span="24">
  392. <a-form-item label="备注"
  393. name="Remark">
  394. <a-input class="dialogInput"
  395. style="width: 608px"
  396. v-model:value="formState.Remark"
  397. placeholder="请输入备注" />
  398. </a-form-item>
  399. </a-col>
  400. </a-row>
  401. </fieldset>
  402. </a-form>
  403. <a-modal :visible="previewVisible"
  404. :footer="null"
  405. @cancel="cancelImg">
  406. <img alt="预览附件"
  407. style="width: 100%"
  408. :src="previewImage" />
  409. </a-modal>
  410. </a-modal>
  411. </template>
  412. <script lang="ts">
  413. import { defineComponent, PropType, ref } from 'vue';
  414. import { getUserName, getUsrId } from '@/services/bus/user';
  415. import { getGoodsList } from '@/services/bus/goods';
  416. import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
  417. import { FormState } from '../interface';
  418. import { formatTime } from '@/common/methods/format';
  419. import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
  420. import moment, { Moment } from 'moment';
  421. import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
  422. import { addContractReq } from '@/views/information/spot-contract/components/add/setup';
  423. import { mergeTwoObj } from '@/utils/objHandle';
  424. import { validateAction } from '@/common/setup/form';
  425. import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
  426. import { handlerManagerList } from '@/common/setup/user';
  427. import { getUploadImg } from '@/common/setup/upload';
  428. import UploadImg from '@/common/components/uploadImg/index.vue';
  429. import { _closeModal } from '@/common/setup/modal/modal';
  430. export default defineComponent({
  431. name: 'spot_contract_btn_modify',
  432. emits: ['cancel', 'update'],
  433. props: {
  434. selectedRow: {
  435. type: Object as PropType<Ermcp3ContractRsp>,
  436. default: {},
  437. },
  438. },
  439. components: { UploadImg },
  440. setup(props, context) {
  441. const { visible, cancel } = _closeModal(context);
  442. const loading = ref<boolean>(false);
  443. const { sendReq } = addContractReq();
  444. const { formState, businessType } = handleFromState();
  445. // 表单
  446. const formRef = ref();
  447. const { rules } = handleFormRule(formState);
  448. // 合同类型
  449. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract(formState);
  450. // 处理现货商品
  451. const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
  452. // 价格信息
  453. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  454. // 日期
  455. const { deliveryDate, priceDate, disabledDate } = handleDate();
  456. // 处理金额
  457. const { getAmout } = handleAmout(formState);
  458. // 获取 业务账户
  459. const { queryTable: queryBusinessManager, getBusinesserOrMerchandiser } = handlerManagerList(loading, 1);
  460. const { tableList: traderList, queryTable: queryTradeManager } = handlerManagerList(loading, 2, true);
  461. // 业务员
  462. const businesserList = ref<ErmcpLoginUser[]>([]);
  463. // 跟单员
  464. const merchandiserList = ref<ErmcpLoginUser[]>([]);
  465. // 现货商品列表
  466. const goodsList = ref<Goods[]>([]);
  467. const { uploadImgAction, uploadImgList, handleImg } = getUploadImg();
  468. queryCustomList();
  469. getDeliveryGoods();
  470. goodsList.value = getGoodsList();
  471. queryBusinessManager().then(() => {
  472. businesserList.value = getBusinesserOrMerchandiser('22');
  473. merchandiserList.value = getBusinesserOrMerchandiser('23');
  474. });
  475. queryTradeManager();
  476. mergeTwoObj(formState, props.selectedRow);
  477. isSell.value = formState.ContractType === 1 ? false : true;
  478. const { deliverygoodsid, qty, price, wrstandardid, spotgoodsbrandid, currencyid, attachment, deliverystartdate, deliveryenddate, startdate, enddate } = props.selectedRow;
  479. if (deliverygoodsid) {
  480. deliveryGoodsChange(deliverygoodsid);
  481. if (wrstandardid) {
  482. WrStandardChange(wrstandardid);
  483. formState.WrStandardID = wrstandardid;
  484. formState.SpotGoodsBrandID = spotgoodsbrandid;
  485. }
  486. }
  487. formState.Qty = qty.toString();
  488. formState.Price = price.toString();
  489. formState.CurrencyID = currencyid;
  490. formState.ContractAttachment = attachment;
  491. if (deliverystartdate) {
  492. deliveryDate.value.push(moment(deliverystartdate));
  493. }
  494. if (deliveryenddate) {
  495. deliveryDate.value.push(moment(deliveryenddate));
  496. }
  497. if (startdate) {
  498. priceDate.value.push(moment(startdate));
  499. }
  500. if (enddate) {
  501. priceDate.value.push(moment(enddate));
  502. }
  503. if (attachment) {
  504. uploadImgList.value = handleImg(attachment);
  505. }
  506. function submit() {
  507. validateAction<FormState>(formRef, formState).then((param) => {
  508. const id = getUsrId();
  509. isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
  510. const fn = (value: Moment) => {
  511. return formatTime(value, 'd') + ' ' + '00:00:00';
  512. };
  513. // 交收期
  514. const dDate = deliveryDate.value;
  515. if (dDate.length) {
  516. const DeliveryStartDate = fn(dDate[0]);
  517. const DeliveryEndDate = fn(dDate[1]);
  518. Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
  519. }
  520. // 点价期
  521. const pDate = priceDate.value;
  522. if (pDate.length && param.PriceType !== 1) {
  523. // 点价日期[2:点价3:暂定价]
  524. const StartDate = fn(pDate[0]);
  525. const EndDate = fn(pDate[1]);
  526. Object.assign(param, { StartDate, EndDate });
  527. }
  528. sendReq(param, loading, 2)
  529. .then((res) => {
  530. cancel(true);
  531. })
  532. .catch((err) => {});
  533. });
  534. }
  535. return {
  536. visible,
  537. cancel,
  538. submit,
  539. formRef,
  540. loading,
  541. maskClosableFlag: false,
  542. formState,
  543. rules,
  544. businessType,
  545. contractType,
  546. isSell,
  547. contractChange,
  548. customList,
  549. deliveryGoodsList,
  550. gblist,
  551. gmlist,
  552. deliveryGoodsChange,
  553. WrStandardChange,
  554. priceType,
  555. payCurrency,
  556. payCurrencyUnit,
  557. parCurrencyChange,
  558. numberUnit,
  559. getUserName,
  560. deliveryDate,
  561. priceDate,
  562. disabledDate,
  563. goodsList,
  564. getAmout,
  565. traderList,
  566. businesserList,
  567. merchandiserList,
  568. uploadImgAction,
  569. uploadImgList,
  570. };
  571. },
  572. });
  573. </script>
  574. <style lang="less">
  575. .modify-custom {
  576. }
  577. </style
  578. >;