index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. :min="0"
  267. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  268. style="width: 200px" />
  269. </a-form-item>
  270. </a-col>
  271. <a-col :span="12">
  272. <a-form-item label="点价期">
  273. <a-range-picker v-model:value="priceDate"
  274. class="commonPicker"
  275. :disabled-date="disabledDate"
  276. style="width: 200px"
  277. :show-time="{hideDisabledOptions: true}"
  278. format="YYYY-MM-DD" />
  279. </a-form-item>
  280. </a-col>
  281. <a-col :span="12">
  282. <a-form-item label="交收期">
  283. <a-range-picker v-model:value="deliveryDate"
  284. class="commonPicker"
  285. style="width: 200px"
  286. :disabled-date="disabledDate"
  287. :show-time="{hideDisabledOptions: true}"
  288. format="YYYY-MM-DD" />
  289. </a-form-item>
  290. </a-col>
  291. </template>
  292. <!-- 以上是点价的价格信息 end -->
  293. <template v-if="formState.PriceType === 1">
  294. <a-col :span="12">
  295. <a-form-item label="价格"
  296. name="Price">
  297. <a-input class="dialogInput suffixGrey"
  298. v-model:value="formState.Price"
  299. @change="getAmout"
  300. placeholder="请输入价格"
  301. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  302. style="width: 200px" />
  303. </a-form-item>
  304. </a-col>
  305. <a-col :span="12">
  306. <a-form-item label="金额"
  307. class="relative"
  308. name="Amount">
  309. <a-input class="dialogInput suffixGrey"
  310. v-model:value="formState.Amount"
  311. readonly
  312. placeholder="输入数量和价格后自动算"
  313. :suffix="payCurrencyUnit"
  314. style="width: 200px" />
  315. </a-form-item>
  316. </a-col>
  317. <a-col :span="24">
  318. <a-form-item label="交收期">
  319. <a-range-picker v-model:value="deliveryDate"
  320. style="width: 200px"
  321. class="commonPicker"
  322. :disabled-date="disabledDate"
  323. :show-time="{hideDisabledOptions: true}"
  324. format="YYYY-MM-DD" />
  325. </a-form-item>
  326. </a-col>
  327. </template>
  328. </a-row>
  329. </fieldset>
  330. <fieldset class="formFieldSet">
  331. <legend>其他信息</legend>
  332. <a-row :gutter="24">
  333. <a-col :span="12">
  334. <a-form-item label="保证金"
  335. name="ContractMargin">
  336. <a-input class="dialogInput suffixGrey"
  337. placeholder="请输入保证金"
  338. v-model:value="formState.ContractMargin"
  339. style="width: 200px"
  340. :suffix="payCurrencyUnit" />
  341. </a-form-item>
  342. </a-col>
  343. <a-col :span="12">
  344. <a-form-item label="业务员"
  345. name="SaleUserID">
  346. <a-select class="inlineFormSelect"
  347. v-model:value="formState.SaleUserID"
  348. style="width: 200px"
  349. placeholder="请选择业务员">
  350. <a-select-option v-for="item in businesserList"
  351. :key="item.userid"
  352. :value="item.userid">
  353. {{item.accountname}}-{{item.logincode}}
  354. </a-select-option>
  355. </a-select>
  356. </a-form-item>
  357. </a-col>
  358. </a-row>
  359. <a-row :gutter="24">
  360. <a-col :span="12">
  361. <a-form-item label="跟单员"
  362. name="MerUserID">
  363. <a-select class="inlineFormSelect"
  364. v-model:value="formState.MerUserID"
  365. style="width: 200px"
  366. placeholder="请选择跟单员">
  367. <a-select-option v-for="item in merchandiserList"
  368. :key="item.userid"
  369. :value="item.userid">
  370. {{item.accountname}}-{{item.logincode}}
  371. </a-select-option>
  372. </a-select>
  373. </a-form-item>
  374. </a-col>
  375. <a-col :span="12">
  376. <a-form-item label="交易用户"
  377. name="TradeUserID">
  378. <a-select class="inlineFormSelect"
  379. style="width: 200px"
  380. v-model:value="formState.TradeUserID"
  381. placeholder="请选择期货账户">
  382. <a-select-option v-for="item in traderList"
  383. :key="item.roleid"
  384. :value="item.roleid">
  385. {{item.rolename}}
  386. </a-select-option>
  387. </a-select>
  388. </a-form-item>
  389. </a-col>
  390. </a-row>
  391. <a-row :gutter="24">
  392. <a-col :span="24">
  393. <a-form-item label="备注"
  394. name="Remark">
  395. <a-input class="dialogInput"
  396. style="width: 608px"
  397. v-model:value="formState.Remark"
  398. placeholder="请输入备注" />
  399. </a-form-item>
  400. </a-col>
  401. </a-row>
  402. </fieldset>
  403. </a-form>
  404. <a-modal :visible="previewVisible"
  405. :footer="null"
  406. @cancel="cancelImg">
  407. <img alt="预览附件"
  408. style="width: 100%"
  409. :src="previewImage" />
  410. </a-modal>
  411. </a-modal>
  412. </template>
  413. <script lang="ts">
  414. import { defineComponent, PropType, ref } from 'vue';
  415. import { getUserName, getUsrId } from '@/services/bus/user';
  416. import { getGoodsList } from '@/services/bus/goods';
  417. import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
  418. import { FormState } from '../interface';
  419. import { formatTime } from '@/common/methods/format';
  420. import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
  421. import moment, { Moment } from 'moment';
  422. import { handleFormRule, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, handleFromState } from '../setup';
  423. import { addContractReq } from '@/views/information/spot-contract/components/add/setup';
  424. import { mergeTwoObj } from '@/utils/objHandle';
  425. import { validateAction } from '@/common/setup/form';
  426. import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
  427. import { handlerManagerList } from '@/common/setup/user';
  428. import { getUploadImg } from '@/common/setup/upload';
  429. import UploadImg from '@/common/components/uploadImg/index.vue';
  430. import { _closeModal } from '@/common/setup/modal/modal';
  431. export default defineComponent({
  432. name: 'spot_contract_btn_modify',
  433. emits: ['cancel', 'update'],
  434. props: {
  435. selectedRow: {
  436. type: Object as PropType<Ermcp3ContractRsp>,
  437. default: {},
  438. },
  439. },
  440. components: { UploadImg },
  441. setup(props, context) {
  442. const { visible, cancel } = _closeModal(context);
  443. const loading = ref<boolean>(false);
  444. const { sendReq } = addContractReq();
  445. const { formState, businessType } = handleFromState();
  446. // 表单
  447. const formRef = ref();
  448. const { rules } = handleFormRule(formState);
  449. // 合同类型
  450. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract(formState);
  451. // 处理现货商品
  452. const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
  453. // 价格信息
  454. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  455. // 日期
  456. const { deliveryDate, priceDate, disabledDate } = handleDate();
  457. // 处理金额
  458. const { getAmout } = handleAmout(formState);
  459. // 获取 业务账户
  460. const { queryTable: queryBusinessManager, getBusinesserOrMerchandiser } = handlerManagerList(loading, 1);
  461. const { tableList: traderList, queryTable: queryTradeManager } = handlerManagerList(loading, 2, true);
  462. // 业务员
  463. const businesserList = ref<ErmcpLoginUser[]>([]);
  464. // 跟单员
  465. const merchandiserList = ref<ErmcpLoginUser[]>([]);
  466. // 现货商品列表
  467. const goodsList = ref<Goods[]>([]);
  468. const { uploadImgAction, uploadImgList, handleImg } = getUploadImg();
  469. queryCustomList();
  470. getDeliveryGoods();
  471. goodsList.value = getGoodsList();
  472. queryBusinessManager().then(() => {
  473. businesserList.value = getBusinesserOrMerchandiser('22');
  474. merchandiserList.value = getBusinesserOrMerchandiser('23');
  475. });
  476. queryTradeManager();
  477. mergeTwoObj(formState, props.selectedRow);
  478. isSell.value = formState.ContractType === 1 ? false : true;
  479. const { deliverygoodsid, qty, price, wrstandardid, spotgoodsbrandid, currencyid, attachment, deliverystartdate, deliveryenddate, startdate, enddate, meruserid, tradeuserid } = props.selectedRow;
  480. if (deliverygoodsid) {
  481. deliveryGoodsChange(deliverygoodsid);
  482. if (wrstandardid) {
  483. WrStandardChange(wrstandardid);
  484. formState.WrStandardID = wrstandardid;
  485. formState.SpotGoodsBrandID = spotgoodsbrandid;
  486. }
  487. }
  488. formState.Qty = qty.toString();
  489. formState.Price = price.toString();
  490. formState.CurrencyID = currencyid;
  491. formState.ContractAttachment = attachment;
  492. formState.MerUserID = meruserid;
  493. formState.TradeUserID = tradeuserid;
  494. if (deliverystartdate) {
  495. deliveryDate.value.push(moment(deliverystartdate));
  496. }
  497. if (deliveryenddate) {
  498. deliveryDate.value.push(moment(deliveryenddate));
  499. }
  500. if (startdate) {
  501. priceDate.value.push(moment(startdate));
  502. }
  503. if (enddate) {
  504. priceDate.value.push(moment(enddate));
  505. }
  506. if (attachment) {
  507. uploadImgList.value = handleImg(attachment);
  508. }
  509. function submit() {
  510. validateAction<FormState>(formRef, formState).then((param) => {
  511. const id = getUsrId();
  512. isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
  513. const fn = (value: Moment) => {
  514. return formatTime(value, 'd') + ' ' + '00:00:00';
  515. };
  516. // 交收期
  517. const dDate = deliveryDate.value;
  518. if (dDate.length) {
  519. const DeliveryStartDate = fn(dDate[0]);
  520. const DeliveryEndDate = fn(dDate[1]);
  521. Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
  522. }
  523. // 点价期
  524. const pDate = priceDate.value;
  525. if (pDate.length && param.PriceType !== 1) {
  526. // 点价日期[2:点价3:暂定价]
  527. const StartDate = fn(pDate[0]);
  528. const EndDate = fn(pDate[1]);
  529. Object.assign(param, { StartDate, EndDate });
  530. }
  531. sendReq(param, loading, 2)
  532. .then((res) => {
  533. cancel(true);
  534. })
  535. .catch((err) => {});
  536. });
  537. }
  538. return {
  539. visible,
  540. cancel,
  541. submit,
  542. formRef,
  543. loading,
  544. maskClosableFlag: false,
  545. formState,
  546. rules,
  547. businessType,
  548. contractType,
  549. isSell,
  550. contractChange,
  551. customList,
  552. deliveryGoodsList,
  553. gblist,
  554. gmlist,
  555. deliveryGoodsChange,
  556. WrStandardChange,
  557. priceType,
  558. payCurrency,
  559. payCurrencyUnit,
  560. parCurrencyChange,
  561. numberUnit,
  562. getUserName,
  563. deliveryDate,
  564. priceDate,
  565. disabledDate,
  566. goodsList,
  567. getAmout,
  568. traderList,
  569. businesserList,
  570. merchandiserList,
  571. uploadImgAction,
  572. uploadImgList,
  573. };
  574. },
  575. });
  576. </script>
  577. <style lang="less">
  578. .modify-custom {
  579. }
  580. </style
  581. >;