index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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="cancel">保存草稿</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. name="SellUserID">
  86. <span class="white">{{getUserName()}}</span>
  87. </a-form-item>
  88. </a-col>
  89. </template>
  90. <template v-else>
  91. <a-col :span="12">
  92. <a-form-item label="采购方"
  93. name="BuyUserID">
  94. <span class="white">{{getUserName()}}</span>
  95. </a-form-item>
  96. </a-col>
  97. <a-col :span="12">
  98. <a-form-item label="销售方"
  99. name="SellUserID">
  100. <a-select class="inlineFormSelect"
  101. v-model:value="formState.SellUserID"
  102. style="width: 200px"
  103. placeholder="请选择客户">
  104. <!-- 客户资料列表 正常 -->
  105. <a-select-option :value="i"
  106. v-for="(item, i) in customList"
  107. :key="item.userid">
  108. {{item.customername}}
  109. </a-select-option>
  110. </a-select>
  111. </a-form-item>
  112. </a-col>
  113. </template>
  114. <a-col :span="12">
  115. <a-form-item label="合同附件"
  116. name="ContractAttachment">
  117. <div class="upload">
  118. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  119. :transform-file="transformFile">
  120. <a-button class="uploadBtn">上传</a-button>
  121. </a-upload>
  122. <div class="look">查看附件</div>
  123. </div>
  124. </a-form-item>
  125. </a-col>
  126. </a-row>
  127. </fieldset>
  128. <fieldset class="formFieldSet">
  129. <legend>现货信息</legend>
  130. <a-row :gutter="24">
  131. <a-col :span="12">
  132. <a-form-item label="现货品种"
  133. name="DeliveryGoodsID">
  134. <a-select class="inlineFormSelect"
  135. style="width: 200px"
  136. @change="deliveryGoodsChange"
  137. v-model:value="formState.DeliveryGoodsID"
  138. placeholder="请选择现货品种">
  139. <a-select-option v-for="item in deliveryGoodsList"
  140. :key="item.deliverygoodsid"
  141. :value="item.deliverygoodsid">
  142. {{item.deliverygoodsname}}
  143. </a-select-option>
  144. </a-select>
  145. </a-form-item>
  146. </a-col>
  147. <a-col :span="12">
  148. <a-form-item label="品类"
  149. name="WrStandardID">
  150. <a-select class="inlineFormSelect"
  151. style="width: 200px"
  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. v-model:value="formState.SpotGoodsBrandID"
  169. placeholder="请选择品牌">
  170. <a-select-option v-for="item in gblist"
  171. :key="item.brandid"
  172. :value="item.brandid">
  173. {{item.brandname}}
  174. </a-select-option>
  175. </a-select>
  176. </a-form-item>
  177. </a-col>
  178. <a-col :span="12">
  179. <a-form-item label="标仓系数"
  180. name="ConvertFactor">
  181. <a-input class="dialogInput"
  182. style="width: 200px"
  183. v-model:value="formState.ConvertFactor"
  184. readonly
  185. placeholder="选择品类后自动填入" />
  186. </a-form-item>
  187. </a-col>
  188. <a-col :span="24">
  189. <a-form-item label="商品规格"
  190. name="SpotGoodsDesc">
  191. <a-input class="dialogInput"
  192. style="width: 200px"
  193. v-model:value="formState.SpotGoodsDesc"
  194. placeholder="请输入商品规格" />
  195. </a-form-item>
  196. </a-col>
  197. </a-row>
  198. </fieldset>
  199. <fieldset class="formFieldSet">
  200. <legend>价格信息</legend>
  201. <a-row :gutter="24">
  202. <a-col :span="12">
  203. <a-form-item label="定价类型"
  204. name="PriceType">
  205. <a-select class="inlineFormSelect"
  206. style="width: 200px"
  207. v-model:value="formState.PriceType"
  208. placeholder="请选择定价类型">
  209. <a-select-option v-for="item in priceType"
  210. :key="item.key"
  211. :value="item.key">
  212. {{item.value}}
  213. </a-select-option>
  214. </a-select>
  215. </a-form-item>
  216. </a-col>
  217. <a-col :span="12">
  218. <a-form-item label="结算币种"
  219. name="CurrencyID">
  220. <a-select class="inlineFormSelect"
  221. v-model:value="formState.CurrencyID"
  222. style="width: 200px"
  223. placeholder="请选择结算币种">
  224. <a-select-option v-for="item in payCurrency"
  225. :key="item.enumdicid"
  226. :value="item.enumdicname">
  227. {{item.enumdicname}}
  228. </a-select-option>
  229. </a-select>
  230. </a-form-item>
  231. </a-col>
  232. <a-col :span="12">
  233. <a-form-item label="数量"
  234. name="Qty">
  235. <a-input class="dialogInput suffixGrey"
  236. v-model:value="formState.Qty"
  237. style="width: 200px"
  238. placeholder="请输入数量"
  239. :suffix="numberUnit" />
  240. </a-form-item>
  241. </a-col>
  242. <a-col :span="12"
  243. v-if="formState.PriceType === 3">
  244. <a-form-item label="暂定价">
  245. <a-input class="dialogInput suffixGrey"
  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 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. :show-time="{hideDisabledOptions: true}"
  283. format="YYYY-MM-DD" />
  284. </a-form-item>
  285. </a-col>
  286. <a-col :span="12">
  287. <a-form-item label="交收期">
  288. <a-range-picker v-model:value="deliveryDate"
  289. class="commonPicker"
  290. :disabled-date="disabledDate"
  291. :show-time="{hideDisabledOptions: true}"
  292. format="YYYY-MM-DD" />
  293. </a-form-item>
  294. </a-col>
  295. </template>
  296. <!-- 以上是点价的价格信息 end -->
  297. <template v-if="formState.PriceType === 1">
  298. <a-col :span="12">
  299. <a-form-item label="价格"
  300. name="Price">
  301. <a-input class="dialogInput suffixGrey"
  302. v-model:value="formState.Price"
  303. placeholder="请输入价格"
  304. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  305. style="width: 200px" />
  306. </a-form-item>
  307. </a-col>
  308. <a-col :span="12">
  309. <a-form-item label="金额"
  310. class="relative">
  311. <a-input class="dialogInput suffixGrey"
  312. readonly
  313. placeholder="输入数量和价格后自动算"
  314. :suffix="payCurrencyUnit"
  315. style="width: 200px" />
  316. </a-form-item>
  317. </a-col>
  318. <a-col :span="24">
  319. <a-form-item label="交收期">
  320. <a-range-picker v-model:value="deliveryDate"
  321. style="width: 200px"
  322. class="commonPicker"
  323. :disabled-date="disabledDate"
  324. :show-time="{hideDisabledOptions: true}"
  325. format="YYYY-MM-DD" />
  326. <!-- <a-select class="inlineFormSelect"
  327. style="width: 95px"
  328. placeholder="请选择定价类型">
  329. <a-select-option value="1">
  330. 日期一
  331. </a-select-option>
  332. </a-select>
  333. <span class="to">-</span>
  334. <a-select class="inlineFormSelect"
  335. style="width: 95px"
  336. placeholder="请选择定价类型">
  337. <a-select-option value="1">
  338. 日期二
  339. </a-select-option>
  340. </a-select> -->
  341. </a-form-item>
  342. </a-col>
  343. </template>
  344. </a-row>
  345. </fieldset>
  346. <fieldset class="formFieldSet">
  347. <legend>其他信息</legend>
  348. <a-row :gutter="24">
  349. <a-col :span="12">
  350. <a-form-item label="保证金">
  351. <a-input class="dialogInput suffixGrey"
  352. placeholder="请输入保证金"
  353. style="width: 200px"
  354. :suffix="payCurrencyUnit" />
  355. </a-form-item>
  356. </a-col>
  357. <a-col :span="12">
  358. <a-form-item label="业务员">
  359. <a-select class="inlineFormSelect"
  360. style="width: 200px"
  361. placeholder="请选择业务员">
  362. <a-select-option value="1">
  363. 客户一
  364. </a-select-option>
  365. <a-select-option value="2">
  366. 客户二
  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. <a-select class="inlineFormSelect"
  376. style="width: 200px"
  377. placeholder="请选择跟单员">
  378. <a-select-option value="1">
  379. 客户一
  380. </a-select-option>
  381. <a-select-option value="2">
  382. 客户二
  383. </a-select-option>
  384. </a-select>
  385. </a-form-item>
  386. </a-col>
  387. <a-col :span="12">
  388. <a-form-item label="期货账户">
  389. <a-select class="inlineFormSelect"
  390. style="width: 200px"
  391. placeholder="请选择期货账户">
  392. <a-select-option value="1">
  393. 客户一
  394. </a-select-option>
  395. <a-select-option value="2">
  396. 客户二
  397. </a-select-option>
  398. </a-select>
  399. </a-form-item>
  400. </a-col>
  401. </a-row>
  402. <a-row :gutter="24">
  403. <a-col :span="24">
  404. <a-form-item label="备注">
  405. <a-input class="dialogInput"
  406. style="width: 608px"
  407. placeholder="请输入备注" />
  408. </a-form-item>
  409. </a-col>
  410. </a-row>
  411. </fieldset>
  412. </a-form>
  413. </a-modal>
  414. </template>
  415. <script lang="ts">
  416. import { defineComponent, ref } from 'vue';
  417. import { closeModal } from '@/common/setup/modal/index';
  418. import { initData } from '@/common/methods';
  419. import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handlePrice, handleDate } from './setup';
  420. import { getUserName } from '@/services/bus/user';
  421. import { getGoodsList } from '@/services/bus/goods';
  422. import { Goods } from '@/services/go/ermcp/goodsInfo/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. loading.value = true;
  464. setTimeout(() => {
  465. loading.value = false;
  466. cancel();
  467. }, 2000);
  468. }
  469. initData(() => {
  470. queryCustomList();
  471. getDeliveryGoods();
  472. goodsList.value = getGoodsList();
  473. });
  474. return {
  475. visible,
  476. cancel,
  477. submit,
  478. loading,
  479. maskClosableFlag: false,
  480. formState,
  481. rules,
  482. businessType,
  483. contractType,
  484. isSell,
  485. contractChange,
  486. customList,
  487. deliveryGoodsList,
  488. gblist,
  489. gmlist,
  490. deliveryGoodsChange,
  491. WrStandardChange,
  492. priceType,
  493. payCurrency,
  494. payCurrencyUnit,
  495. parCurrencyChange,
  496. numberUnit,
  497. getUserName,
  498. deliveryDate,
  499. priceDate,
  500. disabledDate,
  501. goodsList,
  502. };
  503. },
  504. });
  505. </script>
  506. <style lang="less">
  507. .add-spot-contract {
  508. }
  509. </style>;