index.vue 24 KB

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