index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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="cancel"
  9. width="890px">
  10. <template #footer>
  11. <a-button key="submit"
  12. class="cancelBtn"
  13. @click="submit">保存草稿</a-button>
  14. <a-button key="submit"
  15. type="primary"
  16. :loading="loading"
  17. @click="submit">提交审核</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="i"
  76. v-for="(item, i) in customList"
  77. :key="item.userid">
  78. {{item.customername}}
  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="i"
  104. v-for="(item, i) in customList"
  105. :key="item.userid">
  106. {{item.customername}}
  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.enumdicname">
  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. placeholder="请输入数量"
  237. :suffix="numberUnit" />
  238. </a-form-item>
  239. </a-col>
  240. <a-col :span="12"
  241. v-if="formState.PriceType === 3">
  242. <a-form-item label="暂定价">
  243. <a-input class="dialogInput suffixGrey"
  244. :suffix="payCurrencyUnit"
  245. placeholder="请输入暂定价" />
  246. </a-form-item>
  247. </a-col>
  248. <!-- 以下是点价的价格信息 start -->
  249. <template v-if="formState.PriceType === 2 || formState.PriceType === 3">
  250. <a-col :span="12">
  251. <a-form-item label="点价合约"
  252. name="GoodsID">
  253. <a-select class="inlineFormSelect"
  254. v-model:value="formState.GoodsID"
  255. style="width: 200px"
  256. placeholder="请选择点价合约">
  257. <a-select-option v-for="item in goodsList"
  258. :key="item.goodsid"
  259. :value="item.goodsid">
  260. {{item.goodsname}}
  261. </a-select-option>
  262. </a-select>
  263. </a-form-item>
  264. </a-col>
  265. <a-col :span="12">
  266. <a-form-item label="升贴水"
  267. name="PriceMove">
  268. <a-input class="dialogInput suffixGrey"
  269. v-model:value="formState.PriceMove"
  270. placeholder="请输入升贴水"
  271. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  272. style="width: 200px" />
  273. </a-form-item>
  274. </a-col>
  275. <a-col :span="12">
  276. <a-form-item label="点价期">
  277. <a-range-picker v-model:value="priceDate"
  278. class="commonPicker"
  279. :disabled-date="disabledDate"
  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. :disabled-date="disabledDate"
  289. :show-time="{hideDisabledOptions: true}"
  290. format="YYYY-MM-DD" />
  291. </a-form-item>
  292. </a-col>
  293. </template>
  294. <!-- 以上是点价的价格信息 end -->
  295. <template v-if="formState.PriceType === 1">
  296. <a-col :span="12">
  297. <a-form-item label="价格"
  298. name="Price">
  299. <a-input class="dialogInput suffixGrey"
  300. v-model:value="formState.Price"
  301. placeholder="请输入价格"
  302. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  303. style="width: 200px" />
  304. </a-form-item>
  305. </a-col>
  306. <a-col :span="12">
  307. <a-form-item label="金额"
  308. class="relative">
  309. <a-input class="dialogInput suffixGrey"
  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-select class="inlineFormSelect"
  325. style="width: 95px"
  326. placeholder="请选择定价类型">
  327. <a-select-option value="1">
  328. 日期一
  329. </a-select-option>
  330. </a-select>
  331. <span class="to">-</span>
  332. <a-select class="inlineFormSelect"
  333. style="width: 95px"
  334. placeholder="请选择定价类型">
  335. <a-select-option value="1">
  336. 日期二
  337. </a-select-option>
  338. </a-select> -->
  339. </a-form-item>
  340. </a-col>
  341. </template>
  342. </a-row>
  343. </fieldset>
  344. <fieldset class="formFieldSet">
  345. <legend>其他信息</legend>
  346. <a-row :gutter="24">
  347. <a-col :span="12">
  348. <a-form-item label="保证金">
  349. <a-input class="dialogInput suffixGrey"
  350. placeholder="请输入保证金"
  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. <a-select class="inlineFormSelect"
  358. style="width: 200px"
  359. placeholder="请选择业务员">
  360. <a-select-option value="1">
  361. 客户一
  362. </a-select-option>
  363. <a-select-option value="2">
  364. 客户二
  365. </a-select-option>
  366. </a-select>
  367. </a-form-item>
  368. </a-col>
  369. </a-row>
  370. <a-row :gutter="24">
  371. <a-col :span="12">
  372. <a-form-item label="跟单员">
  373. <a-select class="inlineFormSelect"
  374. style="width: 200px"
  375. placeholder="请选择跟单员">
  376. <a-select-option value="1">
  377. 客户一
  378. </a-select-option>
  379. <a-select-option value="2">
  380. 客户二
  381. </a-select-option>
  382. </a-select>
  383. </a-form-item>
  384. </a-col>
  385. <a-col :span="12">
  386. <a-form-item label="期货账户">
  387. <a-select class="inlineFormSelect"
  388. style="width: 200px"
  389. placeholder="请选择期货账户">
  390. <a-select-option value="1">
  391. 客户一
  392. </a-select-option>
  393. <a-select-option value="2">
  394. 客户二
  395. </a-select-option>
  396. </a-select>
  397. </a-form-item>
  398. </a-col>
  399. </a-row>
  400. <a-row :gutter="24">
  401. <a-col :span="24">
  402. <a-form-item label="备注">
  403. <a-input class="dialogInput"
  404. style="width: 608px"
  405. placeholder="请输入备注" />
  406. </a-form-item>
  407. </a-col>
  408. </a-row>
  409. </fieldset>
  410. </a-form>
  411. </a-modal>
  412. </template>
  413. <script lang="ts">
  414. import { defineComponent, ref, toRaw } from 'vue';
  415. import { closeModal } from '@/common/setup/modal/index';
  416. import { initData } from '@/common/methods';
  417. import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handlePrice, handleDate } from './setup';
  418. import { getUserName } from '@/services/bus/user';
  419. import { getGoodsList } from '@/services/bus/goods';
  420. import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
  421. import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
  422. import { FormState } from './interface';
  423. export default defineComponent({
  424. name: 'add-spot-contract',
  425. components: {},
  426. setup() {
  427. const { visible, cancel } = closeModal('spot_contract_btn_add');
  428. const loading = ref<boolean>(false);
  429. // 表单
  430. const formRef = ref();
  431. const { formState, businessType } = handleFromState();
  432. // 合同类型
  433. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract();
  434. // 自定义表单验证方法
  435. const { v_ContractType, v_BizType, v_BuyUser, v_SellUser, v_DeliveryGoods, v_WrStandard, v_SpotGoodsBrand, v_PriceType, v_Currency, v_Goods } = handlevalidate(formState);
  436. const rules = {
  437. ContractNo: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
  438. ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
  439. BizType: [{ required: true, validator: v_BizType, trigger: 'change' }],
  440. BuyUserID: [{ required: true, validator: v_BuyUser, trigger: 'change' }],
  441. SellUserID: [{ required: true, validator: v_SellUser, trigger: 'change' }],
  442. DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoods, trigger: 'change' }],
  443. WrStandardID: [{ required: true, validator: v_WrStandard, trigger: 'blur' }],
  444. SpotGoodsBrandID: [{ required: true, validator: v_SpotGoodsBrand, trigger: 'blur' }],
  445. GoodsID: [{ required: true, validator: v_Goods, trigger: 'blur' }],
  446. ConvertFactor: [{ required: true, message: '请选择品类', trigger: 'blur' }],
  447. SpotGoodsDesc: [{ required: true, message: '请输入商品规格', trigger: 'blur' }],
  448. PriceType: [{ required: true, validator: v_PriceType, trigger: 'blur' }],
  449. CurrencyID: [{ required: true, validator: v_Currency, trigger: 'blur' }],
  450. Qty: [{ required: true, message: '请输入数量', trigger: 'blur' }],
  451. Price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
  452. PriceMove: [{ required: true, message: '请输入升贴水', trigger: 'blur' }],
  453. };
  454. // 处理现货商品
  455. const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
  456. // 价格信息
  457. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  458. // 日期
  459. const { deliveryDate, priceDate, disabledDate } = handleDate();
  460. // 现货商品列表
  461. const goodsList = ref<Goods[]>([]);
  462. function submit() {
  463. formRef.value
  464. .validate()
  465. .then(() => {
  466. const param = toRaw(formState);
  467. console.log('values', formState);
  468. })
  469. .catch((error: ValidateErrorEntity<FormState>) => {
  470. console.log('error', error);
  471. });
  472. }
  473. initData(() => {
  474. queryCustomList();
  475. getDeliveryGoods();
  476. goodsList.value = getGoodsList();
  477. });
  478. return {
  479. visible,
  480. cancel,
  481. submit,
  482. formRef,
  483. loading,
  484. maskClosableFlag: false,
  485. formState,
  486. rules,
  487. businessType,
  488. contractType,
  489. isSell,
  490. contractChange,
  491. customList,
  492. deliveryGoodsList,
  493. gblist,
  494. gmlist,
  495. deliveryGoodsChange,
  496. WrStandardChange,
  497. priceType,
  498. payCurrency,
  499. payCurrencyUnit,
  500. parCurrencyChange,
  501. numberUnit,
  502. getUserName,
  503. deliveryDate,
  504. priceDate,
  505. disabledDate,
  506. goodsList,
  507. };
  508. },
  509. });
  510. </script>
  511. <style lang="less">
  512. .add-spot-contract {
  513. }
  514. </style>;