index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <!-- 新增现货品种 -->
  3. <a-modal class="commonModal addSpotVariety"
  4. wrapClassName=""
  5. title="新增现货品种"
  6. v-model:visible="visible"
  7. @cancel="cancel"
  8. centered
  9. :maskClosable="maskClosableFlag"
  10. width="850px">
  11. <template #footer>
  12. <a-button key="submit"
  13. type="primary"
  14. :loading="loading"
  15. @click="submit">完成</a-button>
  16. </template>
  17. <a-form class="inlineForm"
  18. ref="formRef"
  19. :model="formState"
  20. :rules="rules">
  21. <fieldset class="formFieldSet">
  22. <legend>基本信息</legend>
  23. <a-row :gutter="24">
  24. <a-col :span="12">
  25. <a-form-item label="现货品种名称"
  26. name="deliverygoodsname">
  27. <a-input class="dialogInput"
  28. v-model:value="formState.deliverygoodsname"
  29. style="width: 200px"
  30. placeholder="请输入现货品种名称" />
  31. </a-form-item>
  32. </a-col>
  33. <a-col :span="12">
  34. <a-form-item label="现货品种代码"
  35. name="deliverygoodscode">
  36. <a-input class="dialogInput"
  37. style="width: 200px"
  38. v-model:value="formState.deliverygoodscode"
  39. placeholder="请输入现货品种代码" />
  40. </a-form-item>
  41. </a-col>
  42. </a-row>
  43. <a-row :gutter="24">
  44. <a-col :span="24">
  45. <a-form-item label="单位"
  46. name="unitid">
  47. <a-select class="inlineFormSelect"
  48. style="width: 200px"
  49. v-model:value="formState.unitid"
  50. placeholder="请选择单位">
  51. <a-select-option v-for="item in unitList"
  52. :value="item.enumitemname"
  53. :key="item.autoid">
  54. {{item.enumdicname}}
  55. </a-select-option>
  56. </a-select>
  57. </a-form-item>
  58. </a-col>
  59. </a-row>
  60. <a-row :gutter="24">
  61. <a-col :span="24">
  62. <a-form-item label="备注"
  63. name="remark">
  64. <a-input class="dialogInput"
  65. v-model:value="formState.remark"
  66. style="width: 562px"
  67. placeholder="请输入备注" />
  68. </a-form-item>
  69. </a-col>
  70. </a-row>
  71. </fieldset>
  72. <fieldset class="formFieldSet">
  73. <legend>品类信息</legend>
  74. <a-row :gutter="24">
  75. <a-col :span="6">
  76. <span>
  77. <span class="red">*</span>
  78. 品类
  79. </span>
  80. </a-col>
  81. <a-col :span="6">
  82. <span>
  83. <span class="red">*</span>
  84. 单位
  85. </span>
  86. </a-col>
  87. <a-col :span="6">
  88. <span>
  89. <span class="red">*</span>
  90. 标仓系数
  91. </span>
  92. </a-col>
  93. <a-col :span="6">
  94. <span>
  95. 操作
  96. </span>
  97. </a-col>
  98. <template v-for="(domain, index) in formState.gldwrstandards"
  99. :key="domain.index + 'domain'">
  100. <a-col :span="6">
  101. <a-form-item :name="['gldwrstandards',index, 'wrstandardname', ]"
  102. :rules="rules.gldwrstandards.wrstandardname">
  103. <a-input class="dialogInput"
  104. v-model:value="domain.wrstandardname"
  105. placeholder="请输入品类"></a-input>
  106. </a-form-item>
  107. </a-col>
  108. <a-col :span="6">
  109. <a-form-item :name="['gldwrstandards',index,'unitid' ]"
  110. :rules="rules.gldwrstandards.unitid">
  111. <a-select class="inlineFormSelect"
  112. style="width: 200px"
  113. v-model:value="domain.unitid"
  114. placeholder="请选择单位">
  115. <a-select-option v-for="item in unitList"
  116. :value="item.enumitemname"
  117. :key="item.autoid">
  118. {{item.enumdicname}}
  119. </a-select-option>
  120. </a-select>
  121. </a-form-item>
  122. </a-col>
  123. <a-col :span="6">
  124. <a-form-item :name="['gldwrstandards',index,'convertfactor']"
  125. :rules="rules.gldwrstandards.convertfactor">
  126. <a-input class="dialogInput"
  127. v-model:value="domain.convertfactor"
  128. type="number"
  129. placeholder="请输入标仓系数"></a-input>
  130. </a-form-item>
  131. </a-col>
  132. <a-col :span="6">
  133. <a-button class="plusBtn"
  134. @click="deleteOne('gldwrstandards', index)"
  135. v-if="index > 0">
  136. <template #icon>
  137. <MinusOutlined />
  138. </template>
  139. </a-button>
  140. <a-button class="minusBtn"
  141. @click="addOne('gldwrstandards')">
  142. <template #icon>
  143. <PlusOutlined />
  144. </template>
  145. </a-button>
  146. </a-col>
  147. </template>
  148. </a-row>
  149. <!-- <a-table class="dialogTable"
  150. :columns="columns"
  151. :data-source="dataSource"
  152. :pagination="false">
  153. <template #type>
  154. <a-input class="dialogInput"
  155. placeholder="请输入品类"></a-input>
  156. </template>
  157. <template #customType>
  158. <span>
  159. <span class="red">*</span>
  160. 品类
  161. </span>
  162. </template>
  163. <template #unit>
  164. <a-select class="dialogSelect"
  165. placeholder="请选择单位">
  166. <a-select-option value="1">
  167. 一口价
  168. </a-select-option>
  169. <a-select-option value="2">
  170. 一口价2
  171. </a-select-option>
  172. </a-select>
  173. </template>
  174. <template #customUnit>
  175. <span>
  176. <span class="red">*</span>
  177. 单位
  178. </span>
  179. </template>
  180. <template #coefficient>
  181. <a-input class="dialogInput"
  182. placeholder="请输入标仓系数"></a-input>
  183. </template>
  184. <template #customCoefficient>
  185. <span>
  186. <span class="red">*</span>
  187. 标仓系数
  188. </span>
  189. </template>
  190. <template #action>
  191. <a-button class="plusBtn">
  192. <template #icon>
  193. <MinusOutlined />
  194. </template>
  195. </a-button>
  196. <a-button class="minusBtn">
  197. <template #icon>
  198. <PlusOutlined />
  199. </template>
  200. </a-button>
  201. </template>
  202. </a-table> -->
  203. </fieldset>
  204. <fieldset class="formFieldSet">
  205. <legend>品牌信息</legend>
  206. <a-row :gutter="24">
  207. <a-col :span="12">
  208. <span>
  209. <span class="red">*</span>
  210. 品牌
  211. </span>
  212. </a-col>
  213. <a-col :span="12">
  214. <span>
  215. 操作
  216. </span>
  217. </a-col>
  218. <template v-for="(domain, index) in formState.glddgfactoryItems"
  219. :key="domain.index + 'domain'">
  220. <a-col :span="12">
  221. <a-form-item :name="['glddgfactoryItems',index,'dgfactoryitemvalue']"
  222. :rules="rules.glddgfactoryItems.dgfactoryitemvalue">
  223. <a-input class="dialogInput"
  224. v-model:value="domain.dgfactoryitemvalue"
  225. placeholder="请输入品牌"></a-input>
  226. </a-form-item>
  227. </a-col>
  228. <a-col :span="12">
  229. <a-button class="plusBtn"
  230. @click="deleteOne('glddgfactoryItems', index)"
  231. v-if="index > 0">
  232. <template #icon>
  233. <MinusOutlined />
  234. </template>
  235. </a-button>
  236. <a-button class="minusBtn"
  237. @click="addOne('glddgfactoryItems')">
  238. <template #icon>
  239. <PlusOutlined />
  240. </template>
  241. </a-button>
  242. </a-col>
  243. </template>
  244. </a-row>
  245. <!-- <a-table class="dialogTable"
  246. :columns="columns1"
  247. :data-source="dataSource1"
  248. :pagination="false">
  249. <template #type>
  250. <a-input class="dialogInput"
  251. placeholder="请输入品牌"></a-input>
  252. </template>
  253. <template #customType>
  254. <span>
  255. <span class="red">*</span>
  256. 品牌
  257. </span>
  258. </template>
  259. <template #action>
  260. <a-button class="plusBtn">
  261. <template #icon>
  262. <MinusOutlined />
  263. </template>
  264. </a-button>
  265. <a-button class="minusBtn">
  266. <template #icon>
  267. <PlusOutlined />
  268. </template>
  269. </a-button>
  270. </template>
  271. </a-table> -->
  272. </fieldset>
  273. <fieldset class="formFieldSet">
  274. <legend>套保品种信息</legend>
  275. <a-row :gutter="24">
  276. <a-col :span="6">
  277. <span>
  278. <span class="red">*</span>
  279. 套保品种
  280. </span>
  281. </a-col>
  282. <a-col :span="6">
  283. <span>
  284. <span class="red">*</span>
  285. 单位
  286. </span>
  287. </a-col>
  288. <a-col :span="6">
  289. <span>
  290. <span class="red">*</span>
  291. 套保系数
  292. </span>
  293. </a-col>
  294. <a-col :span="6">
  295. <span>
  296. 操作
  297. </span>
  298. </a-col>
  299. <template v-for="(domain, index) in formState.wrsconvertdetails"
  300. :key="domain.index + 'domain'">
  301. <a-col :span="6">
  302. <a-form-item :name="['wrsconvertdetails',index,'middlegoodsid']"
  303. :rules="rules.wrsconvertdetails.middlegoodsid">
  304. <a-select class="inlineFormSelect"
  305. style="width: 200px"
  306. @change="middleChange(domain.middlegoodsid, domain)"
  307. v-model:value="domain.middlegoodsid"
  308. placeholder="请选择套保品种">
  309. <a-select-option v-for="item in goodsGroup"
  310. :value="item.groupcategroyid"
  311. :key="item.groupcategroyid">
  312. {{item.goodsgroupname}}
  313. </a-select-option>
  314. </a-select>
  315. </a-form-item>
  316. </a-col>
  317. <a-col :span="6">
  318. <a-form-item :name="['wrsconvertdetails', index, 'unitidName']">
  319. <a-input class="dialogInput"
  320. readonly
  321. v-model:value="domain.unitidName"
  322. placeholder="选择套保品种后自动填入"></a-input>
  323. </a-form-item>
  324. </a-col>
  325. <a-col :span="6">
  326. <a-form-item :name="['wrsconvertdetails', index, 'convertratio']"
  327. :rules="rules.wrsconvertdetails.convertratio">
  328. <a-input class="dialogInput"
  329. v-model:value="domain.convertratio"
  330. type="number"
  331. placeholder="请输入套保系数"></a-input>
  332. </a-form-item>
  333. </a-col>
  334. <a-col :span="6">
  335. <a-button class="plusBtn"
  336. @click="deleteOne('wrsconvertdetails', index)"
  337. v-if="index > 0">
  338. <template #icon>
  339. <MinusOutlined />
  340. </template>
  341. </a-button>
  342. <a-button class="minusBtn"
  343. @click="addOne('wrsconvertdetails')">
  344. <template #icon>
  345. <PlusOutlined />
  346. </template>
  347. </a-button>
  348. </a-col>
  349. </template>
  350. </a-row>
  351. <!-- <a-table class="dialogTable"
  352. :columns="columns"
  353. :data-source="dataSource"
  354. :pagination="false">
  355. <template #type>
  356. <a-select class="dialogSelect"
  357. placeholder="请选择套保品种">
  358. <a-select-option value="1">
  359. 一口价
  360. </a-select-option>
  361. <a-select-option value="2">
  362. 一口价2
  363. </a-select-option>
  364. </a-select>
  365. </template>
  366. <template #customType>
  367. <span>
  368. <span class="red">*</span>
  369. 套保品种
  370. </span>
  371. </template>
  372. <template #unit>
  373. <span class="white">选择套保品种后自动填入</span>
  374. </template>
  375. <template #customUnit>
  376. <span>
  377. 单位
  378. </span>
  379. </template>
  380. <template #coefficient>
  381. <a-input class="dialogInput"
  382. placeholder="请输入套保系数"></a-input>
  383. </template>
  384. <template #customCoefficient>
  385. <span>
  386. <span class="red">*</span>
  387. 套保系数
  388. </span>
  389. </template>
  390. <template #action>
  391. <a-button class="plusBtn">
  392. <template #icon>
  393. <MinusOutlined />
  394. </template>
  395. </a-button>
  396. <a-button class="minusBtn">
  397. <template #icon>
  398. <PlusOutlined />
  399. </template>
  400. </a-button>
  401. </template>
  402. </a-table> -->
  403. </fieldset>
  404. </a-form>
  405. </a-modal>
  406. </template>
  407. <script lang="ts">
  408. import { defineComponent, ref, toRaw } from 'vue';
  409. import { closeModal } from '@/common/setup/modal/index';
  410. import { initData } from '@/common/methods/index';
  411. import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
  412. import { handleAdd, handleFromState, handleGoodsGroup, getGoodsUnit } from './setup';
  413. import { getGoodsUnitList } from '../../setup';
  414. import { RuleObject, ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
  415. import { FormState, WRSConvertDetailEx } from './interface';
  416. import { validateCommon } from '@/common/setup/validate';
  417. /**
  418. * 检验单位
  419. */
  420. const validateUnit = async (rule: RuleObject, value: number) => {
  421. return validateCommon(value, '请选择单位');
  422. };
  423. /**
  424. *
  425. */
  426. const valideteWR = async (rule: RuleObject, value: number) => {
  427. return validateCommon(value, '请选择品类');
  428. };
  429. export default defineComponent({
  430. name: 'addSpotVariety',
  431. components: {
  432. PlusOutlined,
  433. MinusOutlined,
  434. },
  435. setup() {
  436. // 控制关闭弹窗
  437. const { visible, cancel } = closeModal('spot_contract_btn_add');
  438. // 下单方法
  439. const { loading, addAction } = handleAdd();
  440. // 单位列表
  441. const unitList = getGoodsUnitList();
  442. const columns = [
  443. {
  444. dataIndex: 'type',
  445. key: 'type',
  446. slots: { title: 'customType', customRender: 'type' },
  447. width: 200,
  448. align: 'center',
  449. },
  450. {
  451. dataIndex: 'unit',
  452. key: 'unit',
  453. slots: { title: 'customUnit', customRender: 'unit' },
  454. width: 200,
  455. align: 'center',
  456. },
  457. {
  458. dataIndex: 'coefficient',
  459. key: 'coefficient',
  460. slots: { title: 'customCoefficient', customRender: 'coefficient' },
  461. width: 200,
  462. align: 'center',
  463. },
  464. {
  465. title: '操作',
  466. key: 'action',
  467. slots: { customRender: 'action' },
  468. align: 'center',
  469. },
  470. ];
  471. const dataSource = [
  472. {
  473. key: '1',
  474. type: 'John Brown',
  475. age: 32,
  476. address: 'New York No. 1 Lake Park',
  477. tags: ['nice', 'developer'],
  478. },
  479. {
  480. key: '2',
  481. name: 'Jim Green',
  482. age: 42,
  483. address: 'London No. 1 Lake Park',
  484. tags: ['loser'],
  485. },
  486. ];
  487. const columns1 = [
  488. {
  489. dataIndex: 'type',
  490. key: 'type',
  491. slots: { title: 'customType', customRender: 'type' },
  492. width: 598,
  493. align: 'center',
  494. },
  495. {
  496. title: '操作',
  497. key: 'action',
  498. slots: { customRender: 'action' },
  499. align: 'center',
  500. },
  501. ];
  502. const dataSource1 = [
  503. {
  504. key: '1',
  505. type: 'John Brown',
  506. age: 32,
  507. address: 'New York No. 1 Lake Park',
  508. tags: ['nice', 'developer'],
  509. },
  510. {
  511. key: '2',
  512. name: 'Jim Green',
  513. age: 42,
  514. address: 'London No. 1 Lake Park',
  515. tags: ['loser'],
  516. },
  517. ];
  518. function submit() {
  519. formRef.value
  520. .validate()
  521. .then(() => {
  522. const param = toRaw(formState);
  523. addAction(param);
  524. console.log('param', param);
  525. })
  526. .catch((error: ValidateErrorEntity<FormState>) => {
  527. console.log('error', error);
  528. });
  529. }
  530. // 表单
  531. const formRef = ref();
  532. const { formState, addOne, deleteOne } = handleFromState();
  533. const rules = {
  534. deliverygoodsname: [{ required: true, message: '请输入现货品种名称', trigger: 'blur' }],
  535. // unitid: [{ required: true, message: '请选择单位', trigger: 'change' }],
  536. unitid: [{ required: true, validator: validateUnit, trigger: 'change' }],
  537. gldwrstandards: {
  538. unitid: { required: true, validator: validateUnit, trigger: 'change' },
  539. wrstandardname: { required: true, message: '请输入品类', trigger: 'blur' },
  540. convertfactor: { required: true, message: '请输入标仓系数', trigger: 'blur' },
  541. },
  542. glddgfactoryItems: {
  543. dgfactoryitemvalue: { required: true, message: '请输入品牌', trigger: 'blur' },
  544. },
  545. wrsconvertdetails: {
  546. middlegoodsid: { required: true, validator: valideteWR, trigger: 'change' },
  547. convertratio: { required: true, message: '请输入套保系数', trigger: 'blur' },
  548. },
  549. };
  550. const { goodsGroup, getGoodsGroup } = handleGoodsGroup();
  551. /**
  552. * 切换套保品种时候,获取对应的单位
  553. */
  554. function middleChange(id: number, value: WRSConvertDetailEx) {
  555. const obj = goodsGroup.value.find((e) => e.groupcategroyid === id);
  556. if (obj) {
  557. value.unitidName = getGoodsUnit(obj.agreeunit);
  558. value.unitid = obj.agreeunit;
  559. }
  560. }
  561. initData(() => {
  562. getGoodsGroup();
  563. });
  564. return {
  565. visible,
  566. cancel,
  567. formRef,
  568. formState,
  569. addOne,
  570. deleteOne,
  571. rules,
  572. unitList,
  573. goodsGroup,
  574. middleChange,
  575. submit,
  576. loading,
  577. dataSource,
  578. columns,
  579. dataSource1,
  580. columns1,
  581. maskClosableFlag: false,
  582. };
  583. },
  584. });
  585. </script>
  586. <style lang="less">
  587. .addSpotVariety {
  588. width: 100%;
  589. height: 100%;
  590. // padding: 30px;
  591. .formFieldSet {
  592. border: 1px solid @m-grey19;
  593. padding: 0 20px 20px;
  594. }
  595. .formFieldSet + .formFieldSet {
  596. margin-top: 35px;
  597. }
  598. .ant-form {
  599. legend {
  600. width: auto;
  601. margin-left: 20px;
  602. font-size: 16px;
  603. color: @m-white0;
  604. border-bottom: 0;
  605. padding: 0 10px;
  606. }
  607. }
  608. .ant-form.inlineForm .ant-row.ant-form-item .ant-form-item-label {
  609. width: 120px !important;
  610. }
  611. .upload {
  612. display: inline-flex;
  613. .ant-btn.uploadBtn {
  614. width: 60px;
  615. height: 30px;
  616. background: @m-blue0;
  617. border: 0;
  618. padding: 0;
  619. text-align: center;
  620. font-size: 14px;
  621. color: @m-white0;
  622. .rounded-corners(3px);
  623. &:hover {
  624. background: rgba(@m-blue0, 0);
  625. color: rgba(@m-white0, 0.8);
  626. }
  627. }
  628. .look {
  629. color: @m-blue0;
  630. font-size: 14px;
  631. margin-left: 10px;
  632. cursor: pointer;
  633. }
  634. }
  635. .red {
  636. color: @m-red1;
  637. }
  638. .ant-btn.minusBtn,
  639. .ant-btn.plusBtn {
  640. width: 26px;
  641. height: 26px;
  642. .inlineflex;
  643. justify-content: center;
  644. background: @m-blue0;
  645. .rounded-corners(3px);
  646. border: 0;
  647. .anticon {
  648. font-size: 12px;
  649. color: @m-white0;
  650. align-self: center;
  651. align-items: center;
  652. }
  653. &:hover,
  654. &:focus {
  655. background: rgba(@m-blue0, 0.8);
  656. .anticon {
  657. color: rgba(@m-white0, 0.8);
  658. }
  659. }
  660. }
  661. .ant-btn.plusBtn {
  662. margin-right: 10px;
  663. background: transparent;
  664. border: 1px solid #3a87f7;
  665. .anticon {
  666. color: @m-blue0;
  667. }
  668. }
  669. .white {
  670. color: @m-white0;
  671. }
  672. .dialogTable {
  673. .ant-table {
  674. .ant-table-content {
  675. .ant-table-body {
  676. table {
  677. tr {
  678. td {
  679. padding: 0;
  680. .ant-input.dialogInput {
  681. height: 34px;
  682. line-height: 34px;
  683. border: 0;
  684. border-radius: 0;
  685. }
  686. .dialogSelect.ant-select-single {
  687. float: left;
  688. margin-right: 0;
  689. .ant-select-selector {
  690. padding: 0 10px;
  691. height: 34px;
  692. background: @m-grey21;
  693. border: 0;
  694. border-radius: 0;
  695. .ant-select-selection-placeholder {
  696. color: @m-grey10;
  697. text-align: left;
  698. }
  699. }
  700. .ant-select-arrow {
  701. color: @m-blue0;
  702. }
  703. }
  704. }
  705. }
  706. }
  707. }
  708. }
  709. }
  710. }
  711. }
  712. </style>