addEdit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. <template>
  2. <el-dialog
  3. v-loading="loading || detailLoading"
  4. :title="title"
  5. :center="true"
  6. align="left"
  7. top="10vh"
  8. width="1040px"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. element-loading-text="拼命加载中"
  12. element-loading-spinner="el-icon-loading"
  13. element-loading-background="rgba(0, 0, 0, 0.8)"
  14. @close="handleClose"
  15. >
  16. <el-card style="margin: -20px 0 0 0">
  17. <el-row :gutter="10">
  18. <el-col :span="24">
  19. <el-form
  20. ref="ruleForm"
  21. :model="ruleForm"
  22. status-icon
  23. :rules="rulesThis"
  24. label-width="80px"
  25. label-position="left"
  26. class="demo-ruleForm"
  27. size="mini"
  28. >
  29. <el-divider>
  30. <el-tag size="mini">销售订单信息</el-tag>
  31. </el-divider>
  32. <el-row>
  33. <el-col :span="12">
  34. <el-form-item label="销售方公司:" label-width="100px" prop="companyNo">
  35. <p style="font-size: 14px; color: #606266; font-weight: 700">
  36. {{ getCompanyWithCode(ruleForm.companyNo).name }}
  37. </p>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="12">
  41. <el-form-item label="购买方公司" label-width="100px" prop="khNo">
  42. <search-customer
  43. size="mini"
  44. :names="khName"
  45. :disabled="id !== '003'"
  46. :is-detail="type !== 'add'"
  47. :value="ruleForm.khNo"
  48. placeholder="购买方公司"
  49. @searchChange="handleCustomerChange"
  50. />
  51. </el-form-item>
  52. </el-col>
  53. <!-- <el-col :span="7">
  54. <el-form-item label="采购员" prop="buyerid">
  55. <search-account
  56. size="mini"
  57. placeholder="采购员"
  58. level="2"
  59. :value="ruleForm.buyerid"
  60. :names="ruleForm.buyer_name"
  61. :is-detail="true"
  62. @searchChange="handleHandoverName"
  63. />
  64. </el-form-item>
  65. </el-col>-->
  66. <el-col :span="12">
  67. <el-form-item label="商品分类" prop="cat_id">
  68. <company-sort
  69. :value="ruleForm.cat_id"
  70. :placeholder="'商品分类'"
  71. :disabled="id !== '003'"
  72. :size="'mini'"
  73. :company-no="ruleForm.companyNo"
  74. :names="cat_id_name"
  75. :is-detail="type !== 'add'"
  76. @searchChange="goods_class_change"
  77. />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="12">
  81. <el-form-item label="所属平台" prop="platform_id">
  82. <search-terrace
  83. :value="ruleForm.platform_id"
  84. :disabled="id !== '003'"
  85. :size="'mini'"
  86. :is-detail="false"
  87. :is_show="'0'"
  88. :placeholder="'所属平台'"
  89. @searchChange="platform_codesearchChange"
  90. />
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="12">
  94. <el-form-item label="平台订单编号" prop="poCode" label-width="110px">
  95. <el-input
  96. v-model="ruleForm.poCode"
  97. placeholder="平台订单编号"
  98. maxlength="50"
  99. :disabled="id === '007'"
  100. />
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="12">
  104. <el-form-item label="其他单号" prop="workCode">
  105. <template #label>
  106. <p style="margin-left: 10px">其他单号</p>
  107. </template>
  108. <el-input
  109. v-model="ruleForm.workCode"
  110. :disabled="id === '007'"
  111. maxlength="50"
  112. placeholder="其他单号"
  113. />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="12">
  117. <el-form-item label="项目经理" prop="managerid">
  118. <project-manager
  119. size="mini"
  120. disabled
  121. :value="ruleForm.managerid"
  122. :names="ruleForm.manager"
  123. :is-detail="true"
  124. placeholder="项目经理"
  125. @searchChange="managerChange"
  126. style="width: 100%"
  127. />
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-divider>
  132. <el-tag size="mini">收货信息</el-tag>
  133. </el-divider>
  134. <el-row>
  135. <el-col :span="8">
  136. <el-form-item label="收货人" prop="contactor">
  137. <el-input
  138. v-model="ruleForm.contactor"
  139. :disabled="id === '007'"
  140. placeholder="收货人"
  141. maxlength="30"
  142. />
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="8">
  146. <el-form-item label="联系电话" prop="mobile">
  147. <el-input
  148. v-model="ruleForm.mobile"
  149. :disabled="id === '007'"
  150. placeholder="联系电话"
  151. maxlength="11"
  152. />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="8">
  156. <el-form-item label="发货时间" prop="sendtime">
  157. <el-date-picker
  158. :picker-options="pickerOptions"
  159. v-model="ruleForm.sendtime"
  160. value-format="yyyy-MM-dd"
  161. :disabled="id === '007'"
  162. placeholder="发货时间"
  163. style="width: 100%"
  164. type="datetime"
  165. />
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="24">
  169. <el-form-item label="联系地址" prop="addr">
  170. <el-input
  171. v-model="ruleForm.addr"
  172. :disabled="id === '007'"
  173. maxlength="100"
  174. placeholder="联系地址"
  175. />
  176. </el-form-item>
  177. </el-col>
  178. </el-row>
  179. <el-divider>
  180. <el-tag size="mini">商品信息</el-tag>
  181. </el-divider>
  182. <el-row>
  183. <el-col :span="12">
  184. <el-form-item label="供应商" label-width="100px" prop="supplierNo">
  185. <search-supplier
  186. size="mini"
  187. placeholder="供应商"
  188. :value="ruleForm.supplierNo"
  189. :names="supplierName"
  190. :disabled="id === '007'"
  191. :is-detail="type !== 'add'"
  192. @searchChange="handleSupplierChange"
  193. />
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="12">
  197. <el-form-item label="商品名称" prop="goodName">
  198. <el-input
  199. v-model="ruleForm.goodName"
  200. placeholder="商品名称"
  201. maxlength="50"
  202. :disabled="id !== '003'"
  203. />
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. <el-row>
  208. <el-col :span="6">
  209. <el-form-item label="数量" prop="goodNum" label-width="60px">
  210. <el-input-number
  211. v-model="ruleForm.goodNum"
  212. :disabled="id !== '003'"
  213. style="width: 100%"
  214. controls-position="right"
  215. placeholder="数量"
  216. :precision="0"
  217. :min="0"
  218. :step="1"
  219. />
  220. </el-form-item>
  221. </el-col>
  222. <el-col :span="6">
  223. <el-form-item label="销售总额" prop="sale_total">
  224. <el-input-number
  225. v-model="ruleForm.sale_total"
  226. :disabled="id !== '003' || disabledField"
  227. style="width: 100%"
  228. controls-position="right"
  229. placeholder="销售总额"
  230. :precision="2"
  231. :min="0"
  232. :step="0.01"
  233. @change="number_change_total($event, 'sale_total')"
  234. />
  235. </el-form-item>
  236. </el-col>
  237. <el-col :span="6">
  238. <el-form-item label="采购总额" prop="cgd_total">
  239. <el-input-number
  240. v-model="ruleForm.cgd_total"
  241. :disabled="id !== '003' || disabledField"
  242. style="width: 100%"
  243. controls-position="right"
  244. placeholder="采购总额"
  245. :precision="2"
  246. :min="0"
  247. :step="0.01"
  248. @change="number_change_total($event, 'cgd_total')"
  249. />
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="6">
  253. <el-form-item label="采购毛利率" label-width="100px" prop="cgd_tax">
  254. <!-- <el-input-number
  255. v-model="ruleForm.cgd_tax"
  256. style="width: 100%"
  257. :disabled="id === '007'"
  258. controls-position="right"
  259. placeholder="采购毛利率"
  260. :precision="2"
  261. :min="0"
  262. :max="100"
  263. :step="0.01"
  264. @change="number_change($event, 2)"
  265. />-->
  266. <digital-input
  267. :values="ruleForm.cgd_tax"
  268. :placeholder="'采购毛利率'"
  269. :min="0"
  270. :max="100"
  271. :disabled="id === '007' || disabledField"
  272. :position="'right'"
  273. :precision="2"
  274. :size="'mini'"
  275. :controls="false"
  276. :append="'%'"
  277. @reschange="number_change($event, 2)"
  278. />
  279. </el-form-item>
  280. </el-col>
  281. </el-row>
  282. <el-row>
  283. <el-col :span="6">
  284. <el-form-item label="单位" prop="goodUnit" label-width="60px">
  285. <search-unit
  286. :value="ruleForm.goodUnit"
  287. :disabled="type === 'view' || type === 'editCoin'"
  288. :size="'mini'"
  289. :is-detail="type !== 'add'"
  290. :names="unit_name"
  291. :placeholder="'单位'"
  292. @searchChange="unitsearchChange"
  293. />
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="6">
  297. <el-form-item label="销售单价" prop="goodPrice">
  298. <el-input-number
  299. v-model="ruleForm.goodPrice"
  300. :disabled="id !== '003' || disabledField"
  301. style="width: 100%"
  302. controls-position="right"
  303. placeholder="单价"
  304. :precision="2"
  305. :min="0"
  306. :step="0.01"
  307. @change="number_change($event, 1)"
  308. />
  309. </el-form-item>
  310. </el-col>
  311. <el-col :span="6">
  312. <el-form-item label="采购单价" prop="cgdPrice">
  313. <el-input-number
  314. v-model="ruleForm.cgdPrice"
  315. style="width: 100%"
  316. :disabled="id === '007' || disabledField"
  317. controls-position="right"
  318. placeholder="采购单价"
  319. :precision="2"
  320. :min="0"
  321. :step="0.01"
  322. @change="number_change($event, 1)"
  323. />
  324. </el-form-item>
  325. </el-col>
  326. <el-col :span="6">
  327. <el-form-item label="税率" prop="tax">
  328. <search-tax
  329. :disabled="id === '007'"
  330. :value="ruleForm.tax"
  331. :size="'mini'"
  332. :is-detail="type !== 'add'"
  333. :placeholder="'税点'"
  334. @searchChange="handleTaxChange"
  335. />
  336. </el-form-item>
  337. </el-col>
  338. </el-row>
  339. </el-form>
  340. </el-col>
  341. <el-col :span="24" style="text-align: right">
  342. <el-button v-if="id !== '007'" type="primary" @click="submitForm"
  343. >保 存</el-button
  344. >
  345. <el-button @click="showModelThis = false">{{
  346. id == "007" ? "关 闭" : "取 消"
  347. }}</el-button>
  348. </el-col>
  349. </el-row>
  350. </el-card>
  351. </el-dialog>
  352. </template>
  353. <script>
  354. import asyncRequest from "@/apis/service/netOrderEntry/netOrderEnter";
  355. import companyHelper from "@/mixins/companyHelper";
  356. import { accMul, accDiv, accSub, isPhone, isMobile } from "@/utils/validate";
  357. import resToken from "@/mixins/resToken";
  358. const defaultData = {
  359. manager: "",
  360. managerid: [],
  361. addr_code: [],
  362. cgd_total: "",
  363. cgdPrice: "",
  364. // buyerid: "",
  365. // buyer_name: "",
  366. platform_id: "",
  367. cgd_tax: "",
  368. workCode: "",
  369. poCode: "",
  370. khNo: "",
  371. companyNo: "",
  372. contactor: "",
  373. mobile: "",
  374. addr: "",
  375. sendtime: "",
  376. supplierNo: "",
  377. cat_id: "",
  378. goodName: "",
  379. goodNum: "",
  380. goodPrice: "",
  381. sale_total: "",
  382. goodUnit: "",
  383. tax: "",
  384. };
  385. export default {
  386. name: "Terrace",
  387. mixins: [resToken, companyHelper],
  388. props: ["showModel", "id", "sitem"],
  389. data() {
  390. const validatemobile = (rule, value, callback) => {
  391. if (value !== "") {
  392. if (isPhone(value) || isMobile(value)) {
  393. callback();
  394. } else {
  395. callback(new Error("联系电话格式不正确!"));
  396. }
  397. } else {
  398. callback(new Error("请输入联系电话!"));
  399. }
  400. };
  401. return {
  402. loading: false,
  403. detailLoading: false,
  404. title: "添加销售订单信息",
  405. khName: "",
  406. accounts: [],
  407. cat_id_name: "",
  408. showModelThis: this.showModel,
  409. pickerOptions: {
  410. disabledDate: (time) => time.getTime() > new Date(),
  411. },
  412. names: [],
  413. unit_name: "",
  414. companyName: "",
  415. ruleForm: { ...defaultData },
  416. rulesThis: this.rules,
  417. rules: {
  418. goodUnit: [
  419. {
  420. required: true,
  421. message: "请选择单位",
  422. trigger: "blur",
  423. },
  424. ],
  425. // addr_code: [
  426. // {
  427. // type: "array",
  428. // required: true,
  429. // message: "请选择收货省市区",
  430. // trigger: "blur",
  431. // },
  432. // ],
  433. platform_id: [
  434. {
  435. required: true,
  436. message: "请输入所属平台",
  437. trigger: "blur",
  438. },
  439. ],
  440. cgd_tax: [
  441. {
  442. required: true,
  443. message: "请输入采购毛利率",
  444. trigger: "blur",
  445. },
  446. ],
  447. cat_id: [
  448. {
  449. required: true,
  450. message: "请选择商品分类",
  451. trigger: "change",
  452. },
  453. ],
  454. supplierNo: [
  455. {
  456. type: "array",
  457. required: true,
  458. message: "请选择供应商公司",
  459. trigger: "change",
  460. },
  461. ],
  462. qrdType: [
  463. {
  464. required: true,
  465. message: "请输入订单来源",
  466. trigger: "blur",
  467. },
  468. ],
  469. sale_total: [
  470. {
  471. required: true,
  472. message: "请输入货款总金额",
  473. trigger: "blur",
  474. },
  475. ],
  476. // workCode: [
  477. // {
  478. // required: true,
  479. // message: '请输入单据号',
  480. // trigger: 'blur'
  481. // }
  482. // ],
  483. poCode: [
  484. {
  485. required: true,
  486. message: "请输入PO编号",
  487. trigger: "blur",
  488. },
  489. ],
  490. khNo: [
  491. {
  492. type: "array",
  493. required: true,
  494. message: "请选择购买方公司",
  495. trigger: "change",
  496. },
  497. ],
  498. tax: [
  499. {
  500. required: true,
  501. message: "请选择税率",
  502. trigger: "change",
  503. },
  504. ],
  505. companyNo: [
  506. {
  507. required: true,
  508. message: "请选择销售方公司",
  509. trigger: "change",
  510. },
  511. ],
  512. contactor: [
  513. {
  514. required: true,
  515. message: "请输入收货人",
  516. trigger: "blur",
  517. },
  518. ],
  519. mobile: [
  520. {
  521. required: true,
  522. validator: validatemobile,
  523. trigger: "blur",
  524. },
  525. ],
  526. addr: [
  527. {
  528. required: true,
  529. message: "请输入联系地址",
  530. trigger: "blur",
  531. },
  532. ],
  533. sendtime: [
  534. {
  535. required: true,
  536. message: "请输入发货时间",
  537. trigger: "change",
  538. },
  539. ],
  540. goodName: [
  541. {
  542. required: true,
  543. message: "请输入商品名称",
  544. trigger: "blur",
  545. },
  546. ],
  547. goodPrice: [
  548. {
  549. required: true,
  550. message: "请输入销售单价",
  551. trigger: "blur",
  552. },
  553. ],
  554. cgdPrice: [
  555. {
  556. required: true,
  557. message: "请选择采购单价",
  558. trigger: "blur",
  559. },
  560. ],
  561. goodNum: [
  562. {
  563. required: true,
  564. message: "请输入数量",
  565. trigger: "blur",
  566. },
  567. ],
  568. cgd_total: [
  569. {
  570. required: true,
  571. message: "请输入采购总额",
  572. trigger: "blur",
  573. },
  574. ],
  575. },
  576. };
  577. },
  578. computed: {
  579. totalWatchSource() {
  580. const { goodNum, goodPrice } = this.ruleForm;
  581. return { goodNum, goodPrice };
  582. },
  583. cgdTotalWatchSource() {
  584. const { goodNum, cgdPrice } = this.ruleForm;
  585. return { goodNum, cgdPrice };
  586. },
  587. },
  588. watch: {
  589. showModel: function (val) {
  590. this.showModelThis = val;
  591. if (val) {
  592. this.initForm();
  593. }
  594. },
  595. showModelThis(val) {
  596. if (!val) {
  597. this.$emit("cancel");
  598. }
  599. },
  600. // totalWatchSource: {
  601. // handler({ goodPrice, goodNum }) {
  602. // if (goodPrice === 0 || goodNum === 0) {
  603. // this.ruleForm.sale_total = 0
  604. // return
  605. // }
  606. // this.ruleForm.sale_total = accMul(goodPrice, goodNum)
  607. // },
  608. // deep: true
  609. // },
  610. // cgdTotalWatchSource: {
  611. // handler({ cgdPrice, goodNum }) {
  612. // if (cgdPrice === 0 || goodNum === 0) {
  613. // this.ruleForm.cgd_total = 0
  614. // return
  615. // }
  616. // this.ruleForm.cgd_total = accMul(cgdPrice, goodNum)
  617. // },
  618. // deep: true
  619. // }
  620. },
  621. methods: {
  622. async handleHandoverName(e) {
  623. this.ruleForm.buyerid = e && e.id ? [e.id] : "";
  624. this.ruleForm.buyer_name = e && e.label ? e.label : "";
  625. this.$refs.ruleForm.validateField("buyerid");
  626. },
  627. async select_area_change(e) {
  628. this.ruleForm.addr_code = e;
  629. this.$refs.ruleForm.validateField("addr_code");
  630. },
  631. number_change(e, type) {
  632. this.ruleForm[type] = e;
  633. },
  634. handleClose() {
  635. this.showModelThis = false;
  636. this.companyName = "";
  637. this.khName = "";
  638. this.supplierName = "";
  639. this.ruleForm = { ...defaultData };
  640. },
  641. async initForm() {
  642. this.loading = true;
  643. // await this.getAccounts();
  644. if (this.id === "003") {
  645. this.title = "添加销售订单信息";
  646. this.rulesThis = this.rules;
  647. } else if (this.id === "005") {
  648. this.title = "修改销售订单信息";
  649. this.rulesThis = this.rules;
  650. } else {
  651. this.title = "销售订单信息详情";
  652. this.rulesThis = {};
  653. }
  654. await this.resetForm();
  655. this.loading = false;
  656. },
  657. handleCompanyChange(e) {
  658. this.ruleForm.companyNo = e.code || "";
  659. this.$refs.ruleForm.validateField("companyNo");
  660. },
  661. handleCustomerChange(e) {
  662. this.ruleForm.khNo = e.code ? [e.code] : "";
  663. this.$refs.ruleForm.validateField("khNo");
  664. },
  665. handleSupplierChange(e) {
  666. this.ruleForm.supplierNo = e.code ? [e.code] : "";
  667. this.$refs.ruleForm.validateField("supplierNo");
  668. },
  669. handleGoodClassChange(e) {
  670. this.ruleForm.cat_id = e;
  671. this.$refs.ruleForm.validateField("cat_id");
  672. },
  673. handleTaxChange(e) {
  674. this.ruleForm.tax = e;
  675. this.$refs.ruleForm.validateField("tax");
  676. },
  677. unitsearchChange(e) {
  678. const { id, code, label } = e;
  679. this.ruleForm.goodUnit = code ? [code] : [];
  680. this.$refs.ruleForm.validateField("goodUnit");
  681. },
  682. async resetForm() {
  683. // 重置
  684. await this.$nextTick(() => {
  685. if (this.$refs.ruleForm) {
  686. this.$refs.ruleForm.resetFields();
  687. this.$refs.ruleForm.clearValidate();
  688. }
  689. });
  690. if (this.id === "003") {
  691. this.ruleForm.companyNo = this.currentCompany;
  692. return;
  693. }
  694. if (this.id !== "003") this.getDetail();
  695. },
  696. number_change_total(current, prop) {
  697. // const isCgdTotal = prop === 'cgd_total'
  698. // const { goodNum } = this.ruleForm
  699. // this.ruleForm[isCgdTotal ? 'cgdPrice' : 'goodPrice'] = accDiv(current, goodNum)
  700. this.ruleForm[prop] = current;
  701. // let tax = 0
  702. // tax = accMul(accSub(1, accDiv(this.ruleForm.cgd_total, this.ruleForm.sale_total)), 100)
  703. // this.ruleForm.cgd_tax = tax
  704. // if (this.ruleForm.cgd_total && this.ruleForm.sale_total) {
  705. // this.ruleForm['cgd_tax'] = accMul(accDiv(this.ruleForm.cgd_total, this.ruleForm.sale_total), 100) || 0
  706. // }
  707. },
  708. async getDetail() {
  709. this.detailLoading = true;
  710. const { orderCode } = this.sitem;
  711. const { data } = await asyncRequest.detail({ orderCode });
  712. const {
  713. cat_id,
  714. buyerid,
  715. khNo,
  716. supplierNo,
  717. supplierNanme,
  718. khName,
  719. goodUnit,
  720. tax,
  721. addr_code,
  722. unitName,
  723. manager,
  724. managerid,
  725. ...rest
  726. } = data;
  727. this.ruleForm = {
  728. ...rest,
  729. manager: manager || "",
  730. managerid: managerid ? [managerid] : [],
  731. buyerid: buyerid ? [buyerid] : [],
  732. addr_code: addr_code ? addr_code.split(",") : [],
  733. cat_id: cat_id && cat_id.length === 3 ? [cat_id[cat_id.length - 1]] : [],
  734. supplierNo: supplierNo ? [supplierNo] : [],
  735. khNo: khNo ? [khNo] : [],
  736. tax: tax ? tax + "%" : "",
  737. goodUnit: goodUnit ? [goodUnit] : "",
  738. };
  739. this.cat_id_name =
  740. cat_id && cat_id.length === 3 ? cat_id.map(({ name }) => name).join("_") : "";
  741. this.unit_name = unitName;
  742. this.khName = khName;
  743. this.supplierName = supplierNanme;
  744. this.detailLoading = false;
  745. },
  746. platform_codesearchChange(e) {
  747. const { id, label, pay_name } = e;
  748. this.ruleForm.platform_id = id || "";
  749. this.pay_name = pay_name || "";
  750. this.$refs.ruleForm.validateField("platform_id");
  751. },
  752. // async getAccounts() {
  753. // const res = await asyncRequest.accountall(this.dataForm);
  754. // if (res && res.code === 0 && res.data) {
  755. // this.accounts = res.data;
  756. // } else if (res && res.code >= 100 && res.code <= 104) {
  757. // await this.logout();
  758. // } else {
  759. // this.$message.warning(res.message);
  760. // }
  761. // },
  762. async goods_class_change(e) {
  763. const { id } = e;
  764. this.ruleForm.cat_id = id ? [id] : [];
  765. this.$refs.ruleForm.validateField("cat_id");
  766. },
  767. async submitForm() {
  768. console.log(111);
  769. await this.$refs.ruleForm.validate(async (valid) => {
  770. if (valid) {
  771. if (this.loading) {
  772. return;
  773. }
  774. this.loading = true;
  775. const model = JSON.parse(JSON.stringify(this.ruleForm));
  776. model.supplierNo = model.supplierNo[0];
  777. model.khNo = model.khNo[0];
  778. model.buyerid = Array.isArray(model.buyerid) ? model.buyerid[0] : model.buyerid;
  779. model.cat_id = model.cat_id ? model.cat_id[model.cat_id.length - 1] : "";
  780. model.addr_code = model.addr_code.join(",");
  781. model.tax = model.tax.split("%")[0];
  782. model.pay_name = this.pay_name;
  783. model.goodUnit = Array.isArray(model.goodUnit)
  784. ? model.goodUnit[0]
  785. : model.goodUnit;
  786. let res = {};
  787. if (this.id === "003") {
  788. delete model["id"];
  789. res = await asyncRequest.add(model);
  790. } else {
  791. res = await asyncRequest.update(model);
  792. }
  793. this.loading = false;
  794. if (res && res.code === 0) {
  795. const title = this.id === "003" ? "添加成功!" : "修改成功!";
  796. this.$notify.success({
  797. title,
  798. message: "",
  799. });
  800. this.showModelThis = false;
  801. // 刷新
  802. this.$emit("refresh");
  803. } else if (res && res.code >= 100 && res.code <= 104) {
  804. await this.logout();
  805. } else {
  806. this.$message.warning(res.message);
  807. }
  808. } else {
  809. console.log("error submit!!");
  810. return false;
  811. }
  812. });
  813. },
  814. },
  815. };
  816. </script>
  817. <style lang="scss" scoped>
  818. .terrace {
  819. }
  820. </style>