index.vue 22 KB

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