index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. 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. :suffix="payCurrencyUnit"
  246. placeholder="请输入暂定价" />
  247. </a-form-item>
  248. </a-col>
  249. <!-- 以下是点价的价格信息 start -->
  250. <template v-if="formState.PriceType === 2 || formState.PriceType === 3">
  251. <a-col :span="12">
  252. <a-form-item label="点价合约">
  253. <a-select class="inlineFormSelect"
  254. style="width: 200px"
  255. placeholder="请选择点价合约">
  256. <a-select-option value="1">
  257. 合约一
  258. </a-select-option>
  259. <a-select-option value="2">
  260. 合约二
  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. <a-input class="dialogInput suffixGrey"
  268. placeholder="请输入升贴水"
  269. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  270. style="width: 200px" />
  271. </a-form-item>
  272. </a-col>
  273. <a-col :span="12">
  274. <a-form-item label="点价期">
  275. <a-select class="inlineFormSelect"
  276. style="width: 95px"
  277. placeholder="请选择点价期">
  278. <a-select-option value="1">
  279. 日期一
  280. </a-select-option>
  281. </a-select>
  282. <span class="to">-</span>
  283. <a-select class="inlineFormSelect"
  284. style="width: 95px"
  285. placeholder="请选择定价类型">
  286. <a-select-option value="1">
  287. 日期二
  288. </a-select-option>
  289. </a-select>
  290. </a-form-item>
  291. </a-col>
  292. <a-col :span="12">
  293. <a-form-item label="交收期">
  294. <a-select class="inlineFormSelect"
  295. style="width: 95px"
  296. placeholder="请选择定价类型">
  297. <a-select-option value="1">
  298. 日期一
  299. </a-select-option>
  300. </a-select>
  301. <span class="to">-</span>
  302. <a-select class="inlineFormSelect"
  303. style="width: 95px"
  304. placeholder="请选择定价类型">
  305. <a-select-option value="1">
  306. 日期二
  307. </a-select-option>
  308. </a-select>
  309. </a-form-item>
  310. </a-col>
  311. </template>
  312. <!-- 以上是点价的价格信息 end -->
  313. <template v-if="formState.PriceType === 1">
  314. <a-col :span="12">
  315. <a-form-item label="价格"
  316. name="Price">
  317. <a-input class="dialogInput suffixGrey"
  318. v-model:value="formState.Price"
  319. placeholder="请输入价格"
  320. :suffix="`${payCurrencyUnit}/${numberUnit}`"
  321. style="width: 200px" />
  322. </a-form-item>
  323. </a-col>
  324. <a-col :span="12">
  325. <a-form-item label="金额"
  326. class="relative">
  327. <a-input class="dialogInput suffixGrey"
  328. readonly
  329. placeholder="输入数量和价格后自动算"
  330. :suffix="payCurrencyUnit"
  331. style="width: 200px" />
  332. </a-form-item>
  333. </a-col>
  334. <a-col :span="24">
  335. <a-form-item label="交收期">
  336. <a-range-picker v-model:value="deliveryDate"
  337. :disabled-date="disabledDate"
  338. :show-time="{hideDisabledOptions: true}"
  339. format="YYYY-MM-DD" />
  340. <!-- <a-select class="inlineFormSelect"
  341. style="width: 95px"
  342. placeholder="请选择定价类型">
  343. <a-select-option value="1">
  344. 日期一
  345. </a-select-option>
  346. </a-select>
  347. <span class="to">-</span>
  348. <a-select class="inlineFormSelect"
  349. style="width: 95px"
  350. placeholder="请选择定价类型">
  351. <a-select-option value="1">
  352. 日期二
  353. </a-select-option>
  354. </a-select> -->
  355. </a-form-item>
  356. </a-col>
  357. </template>
  358. </a-row>
  359. </fieldset>
  360. <fieldset class="formFieldSet">
  361. <legend>其他信息</legend>
  362. <a-row :gutter="24">
  363. <a-col :span="12">
  364. <a-form-item label="保证金">
  365. <a-input class="dialogInput suffixGrey"
  366. placeholder="请输入保证金"
  367. :suffix="payCurrencyUnit" />
  368. </a-form-item>
  369. </a-col>
  370. <a-col :span="12">
  371. <a-form-item label="业务员">
  372. <a-select class="inlineFormSelect"
  373. style="width: 200px"
  374. placeholder="请选择业务员">
  375. <a-select-option value="1">
  376. 客户一
  377. </a-select-option>
  378. <a-select-option value="2">
  379. 客户二
  380. </a-select-option>
  381. </a-select>
  382. </a-form-item>
  383. </a-col>
  384. </a-row>
  385. <a-row :gutter="24">
  386. <a-col :span="12">
  387. <a-form-item label="跟单员">
  388. <a-select class="inlineFormSelect"
  389. style="width: 200px"
  390. placeholder="请选择跟单员">
  391. <a-select-option value="1">
  392. 客户一
  393. </a-select-option>
  394. <a-select-option value="2">
  395. 客户二
  396. </a-select-option>
  397. </a-select>
  398. </a-form-item>
  399. </a-col>
  400. <a-col :span="12">
  401. <a-form-item label="期货账户">
  402. <a-select class="inlineFormSelect"
  403. style="width: 200px"
  404. placeholder="请选择期货账户">
  405. <a-select-option value="1">
  406. 客户一
  407. </a-select-option>
  408. <a-select-option value="2">
  409. 客户二
  410. </a-select-option>
  411. </a-select>
  412. </a-form-item>
  413. </a-col>
  414. </a-row>
  415. <a-row :gutter="24">
  416. <a-col :span="24">
  417. <a-form-item label="备注">
  418. <a-input class="dialogInput"
  419. style="width: 620px"
  420. placeholder="请输入备注" />
  421. </a-form-item>
  422. </a-col>
  423. </a-row>
  424. </fieldset>
  425. </a-form>
  426. </a-modal>
  427. </template>
  428. <script lang="ts">
  429. import { defineComponent, ref } from 'vue';
  430. import { closeModal } from '@/common/setup/modal/index';
  431. import { initData } from '@/common/methods';
  432. import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handlePrice, handleDate } from './setup';
  433. import { getUserName } from '@/services/bus/user';
  434. export default defineComponent({
  435. name: 'add-spot-contract',
  436. components: {},
  437. setup() {
  438. const { visible, cancel } = closeModal('spot_contract_btn_add');
  439. const loading = ref<boolean>(false);
  440. // 表单
  441. const formRef = ref();
  442. const { formState, businessType } = handleFromState();
  443. // 合同类型
  444. const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract();
  445. // 自定义表单验证方法
  446. const { v_ContractType, v_BizType, v_BuyUser, v_SellUser, v_DeliveryGoods, v_WrStandard, v_SpotGoodsBrand, v_PriceType, v_Currency } = handlevalidate(formState);
  447. const rules = {
  448. ContractNo: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
  449. ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
  450. BizType: [{ required: true, validator: v_BizType, trigger: 'change' }],
  451. BuyUserID: [{ required: true, validator: v_BuyUser, trigger: 'change' }],
  452. SellUserID: [{ required: true, validator: v_SellUser, trigger: 'change' }],
  453. DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoods, trigger: 'change' }],
  454. WrStandardID: [{ required: true, validator: v_WrStandard, trigger: 'blur' }],
  455. SpotGoodsBrandID: [{ required: true, validator: v_SpotGoodsBrand, trigger: 'blur' }],
  456. ConvertFactor: [{ required: true, message: '请选择品类', trigger: 'blur' }],
  457. SpotGoodsDesc: [{ required: true, message: '请输入商品规格', trigger: 'blur' }],
  458. PriceType: [{ required: true, validator: v_PriceType, trigger: 'blur' }],
  459. CurrencyID: [{ required: true, validator: v_Currency, trigger: 'blur' }],
  460. Qty: [{ required: true, message: '请输入数量', trigger: 'blur' }],
  461. Price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
  462. };
  463. // 处理现货商品
  464. const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
  465. // 价格信息
  466. const { priceType, payCurrency, payCurrencyUnit, parCurrencyChange } = handlePrice(formState);
  467. // 日期
  468. const { deliveryDate, disabledDate } = handleDate();
  469. function submit() {
  470. loading.value = true;
  471. setTimeout(() => {
  472. loading.value = false;
  473. cancel();
  474. }, 2000);
  475. }
  476. initData(() => {
  477. queryCustomList();
  478. getDeliveryGoods();
  479. });
  480. return {
  481. visible,
  482. cancel,
  483. submit,
  484. loading,
  485. maskClosableFlag: false,
  486. formState,
  487. rules,
  488. businessType,
  489. contractType,
  490. isSell,
  491. contractChange,
  492. customList,
  493. deliveryGoodsList,
  494. gblist,
  495. gmlist,
  496. deliveryGoodsChange,
  497. WrStandardChange,
  498. priceType,
  499. payCurrency,
  500. payCurrencyUnit,
  501. parCurrencyChange,
  502. numberUnit,
  503. getUserName,
  504. deliveryDate,
  505. disabledDate,
  506. };
  507. },
  508. });
  509. </script>
  510. <style lang="less">
  511. .add-spot-contract {
  512. }
  513. </style>;