addEdit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  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
  36. style="font-size:14px;color:#606266;font-weight:700"
  37. >{{ getCompanyWithCode(ruleForm.companyNo).name }}</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">保 存</el-button>
  343. <el-button @click="showModelThis = false">{{ id == "007" ? "关 闭" : "取 消" }}</el-button>
  344. </el-col>
  345. </el-row>
  346. </el-card>
  347. </el-dialog>
  348. </template>
  349. <script>
  350. import asyncRequest from "@/apis/service/netOrderEntry/netOrderEnter";
  351. import companyHelper from "@/mixins/companyHelper";
  352. import { accMul, accDiv, accSub, isPhone, isMobile } from "@/utils/validate";
  353. import resToken from "@/mixins/resToken";
  354. const defaultData = {
  355. manager:"",
  356. managerid:[],
  357. addr_code: [],
  358. cgd_total: "",
  359. cgdPrice: "",
  360. // buyerid: "",
  361. // buyer_name: "",
  362. platform_id: "",
  363. cgd_tax: "",
  364. workCode: "",
  365. poCode: "",
  366. khNo: "",
  367. companyNo: "",
  368. contactor: "",
  369. mobile: "",
  370. addr: "",
  371. sendtime: "",
  372. supplierNo: "",
  373. cat_id: "",
  374. goodName: "",
  375. goodNum: "",
  376. goodPrice: "",
  377. sale_total: "",
  378. goodUnit: "",
  379. tax: ""
  380. };
  381. export default {
  382. name: "Terrace",
  383. mixins: [resToken, companyHelper],
  384. props: ["showModel", "id", "sitem"],
  385. data() {
  386. const validatemobile = (rule, value, callback) => {
  387. if (value !== "") {
  388. if (isPhone(value) || isMobile(value)) {
  389. callback();
  390. } else {
  391. callback(new Error("联系电话格式不正确!"));
  392. }
  393. } else {
  394. callback(new Error("请输入联系电话!"));
  395. }
  396. };
  397. return {
  398. loading: false,
  399. detailLoading: false,
  400. title: "添加销售订单信息",
  401. khName: "",
  402. accounts: [],
  403. cat_id_name: "",
  404. showModelThis: this.showModel,
  405. pickerOptions: {
  406. disabledDate: time => time.getTime() > new Date()
  407. },
  408. names: [],
  409. unit_name: "",
  410. companyName: "",
  411. ruleForm: { ...defaultData },
  412. rulesThis: this.rules,
  413. rules: {
  414. goodUnit: [
  415. {
  416. required: true,
  417. message: "请选择单位",
  418. trigger: "blur"
  419. }
  420. ],
  421. // addr_code: [
  422. // {
  423. // type: "array",
  424. // required: true,
  425. // message: "请选择收货省市区",
  426. // trigger: "blur",
  427. // },
  428. // ],
  429. platform_id: [
  430. {
  431. required: true,
  432. message: "请输入所属平台",
  433. trigger: "blur"
  434. }
  435. ],
  436. cgd_tax: [
  437. {
  438. required: true,
  439. message: "请输入采购毛利率",
  440. trigger: "blur"
  441. }
  442. ],
  443. cat_id: [
  444. {
  445. required: true,
  446. message: "请选择商品分类",
  447. trigger: "change"
  448. }
  449. ],
  450. supplierNo: [
  451. {
  452. type: "array",
  453. required: true,
  454. message: "请选择供应商公司",
  455. trigger: "change"
  456. }
  457. ],
  458. qrdType: [
  459. {
  460. required: true,
  461. message: "请输入订单来源",
  462. trigger: "blur"
  463. }
  464. ],
  465. sale_total: [
  466. {
  467. required: true,
  468. message: "请输入货款总金额",
  469. trigger: "blur"
  470. }
  471. ],
  472. // workCode: [
  473. // {
  474. // required: true,
  475. // message: '请输入单据号',
  476. // trigger: 'blur'
  477. // }
  478. // ],
  479. poCode: [
  480. {
  481. required: true,
  482. message: "请输入PO编号",
  483. trigger: "blur"
  484. }
  485. ],
  486. khNo: [
  487. {
  488. type: "array",
  489. required: true,
  490. message: "请选择购买方公司",
  491. trigger: "change"
  492. }
  493. ],
  494. tax: [
  495. {
  496. required: true,
  497. message: "请选择税率",
  498. trigger: "change"
  499. }
  500. ],
  501. companyNo: [
  502. {
  503. required: true,
  504. message: "请选择销售方公司",
  505. trigger: "change"
  506. }
  507. ],
  508. contactor: [
  509. {
  510. required: true,
  511. message: "请输入收货人",
  512. trigger: "blur"
  513. }
  514. ],
  515. mobile: [
  516. {
  517. required: true,
  518. validator: validatemobile,
  519. trigger: "blur"
  520. }
  521. ],
  522. addr: [
  523. {
  524. required: true,
  525. message: "请输入联系地址",
  526. trigger: "blur"
  527. }
  528. ],
  529. sendtime: [
  530. {
  531. required: true,
  532. message: "请输入发货时间",
  533. trigger: "change"
  534. }
  535. ],
  536. goodName: [
  537. {
  538. required: true,
  539. message: "请输入商品名称",
  540. trigger: "blur"
  541. }
  542. ],
  543. goodPrice: [
  544. {
  545. required: true,
  546. message: "请输入销售单价",
  547. trigger: "blur"
  548. }
  549. ],
  550. cgdPrice: [
  551. {
  552. required: true,
  553. message: "请选择采购单价",
  554. trigger: "blur"
  555. }
  556. ],
  557. goodNum: [
  558. {
  559. required: true,
  560. message: "请输入数量",
  561. trigger: "blur"
  562. }
  563. ],
  564. cgd_total: [
  565. {
  566. required: true,
  567. message: "请输入采购总额",
  568. trigger: "blur"
  569. }
  570. ]
  571. }
  572. };
  573. },
  574. computed: {
  575. totalWatchSource() {
  576. const { goodNum, goodPrice } = this.ruleForm;
  577. return { goodNum, goodPrice };
  578. },
  579. cgdTotalWatchSource() {
  580. const { goodNum, cgdPrice } = this.ruleForm;
  581. return { goodNum, cgdPrice };
  582. }
  583. },
  584. watch: {
  585. showModel: function(val) {
  586. this.showModelThis = val;
  587. if (val) {
  588. this.initForm();
  589. }
  590. },
  591. showModelThis(val) {
  592. if (!val) {
  593. this.$emit("cancel");
  594. }
  595. }
  596. // totalWatchSource: {
  597. // handler({ goodPrice, goodNum }) {
  598. // if (goodPrice === 0 || goodNum === 0) {
  599. // this.ruleForm.sale_total = 0
  600. // return
  601. // }
  602. // this.ruleForm.sale_total = accMul(goodPrice, goodNum)
  603. // },
  604. // deep: true
  605. // },
  606. // cgdTotalWatchSource: {
  607. // handler({ cgdPrice, goodNum }) {
  608. // if (cgdPrice === 0 || goodNum === 0) {
  609. // this.ruleForm.cgd_total = 0
  610. // return
  611. // }
  612. // this.ruleForm.cgd_total = accMul(cgdPrice, goodNum)
  613. // },
  614. // deep: true
  615. // }
  616. },
  617. methods: {
  618. async handleHandoverName(e) {
  619. this.ruleForm.buyerid = e && e.id ? [e.id] : "";
  620. this.ruleForm.buyer_name = e && e.label ? e.label : "";
  621. this.$refs.ruleForm.validateField("buyerid");
  622. },
  623. async select_area_change(e) {
  624. this.ruleForm.addr_code = e;
  625. this.$refs.ruleForm.validateField("addr_code");
  626. },
  627. number_change(e, type) {
  628. this.ruleForm[type] = e;
  629. },
  630. handleClose() {
  631. this.showModelThis = false;
  632. this.companyName = "";
  633. this.khName = "";
  634. this.supplierName = "";
  635. this.ruleForm = { ...defaultData };
  636. },
  637. async initForm() {
  638. this.loading = true;
  639. // await this.getAccounts();
  640. if (this.id === "003") {
  641. this.title = "添加销售订单信息";
  642. this.rulesThis = this.rules;
  643. } else if (this.id === "005") {
  644. this.title = "修改销售订单信息";
  645. this.rulesThis = this.rules;
  646. } else {
  647. this.title = "销售订单信息详情";
  648. this.rulesThis = {};
  649. }
  650. await this.resetForm();
  651. this.loading = false;
  652. },
  653. handleCompanyChange(e) {
  654. this.ruleForm.companyNo = e.code || "";
  655. this.$refs.ruleForm.validateField("companyNo");
  656. },
  657. handleCustomerChange(e) {
  658. this.ruleForm.khNo = e.code ? [e.code] : "";
  659. this.$refs.ruleForm.validateField("khNo");
  660. },
  661. handleSupplierChange(e) {
  662. this.ruleForm.supplierNo = e.code ? [e.code] : "";
  663. this.$refs.ruleForm.validateField("supplierNo");
  664. },
  665. handleGoodClassChange(e) {
  666. this.ruleForm.cat_id = e;
  667. this.$refs.ruleForm.validateField("cat_id");
  668. },
  669. handleTaxChange(e) {
  670. this.ruleForm.tax = e;
  671. this.$refs.ruleForm.validateField("tax");
  672. },
  673. unitsearchChange(e) {
  674. const { id, code, label } = e;
  675. this.ruleForm.goodUnit = code ? [code] : [];
  676. this.$refs.ruleForm.validateField("goodUnit");
  677. },
  678. async resetForm() {
  679. // 重置
  680. await this.$nextTick(() => {
  681. if (this.$refs.ruleForm) {
  682. this.$refs.ruleForm.resetFields();
  683. this.$refs.ruleForm.clearValidate();
  684. }
  685. });
  686. if (this.id === "003") {
  687. this.ruleForm.companyNo = this.currentCompany;
  688. return;
  689. }
  690. if (this.id !== "003") this.getDetail();
  691. },
  692. number_change_total(current, prop) {
  693. // const isCgdTotal = prop === 'cgd_total'
  694. // const { goodNum } = this.ruleForm
  695. // this.ruleForm[isCgdTotal ? 'cgdPrice' : 'goodPrice'] = accDiv(current, goodNum)
  696. this.ruleForm[prop] = current;
  697. // let tax = 0
  698. // tax = accMul(accSub(1, accDiv(this.ruleForm.cgd_total, this.ruleForm.sale_total)), 100)
  699. // this.ruleForm.cgd_tax = tax
  700. // if (this.ruleForm.cgd_total && this.ruleForm.sale_total) {
  701. // this.ruleForm['cgd_tax'] = accMul(accDiv(this.ruleForm.cgd_total, this.ruleForm.sale_total), 100) || 0
  702. // }
  703. },
  704. async getDetail() {
  705. this.detailLoading = true;
  706. const { orderCode } = this.sitem;
  707. const { data } = await asyncRequest.detail({ orderCode });
  708. const {
  709. cat_id,
  710. buyerid,
  711. khNo,
  712. supplierNo,
  713. supplierNanme,
  714. khName,
  715. goodUnit,
  716. tax,
  717. addr_code,
  718. unitName,
  719. manager,
  720. managerid,
  721. ...rest
  722. } = data;
  723. this.ruleForm = {
  724. ...rest,
  725. manager:manager || "",
  726. managerid:managerid ? [managerid] : [],
  727. buyerid: buyerid ? [buyerid] : [],
  728. addr_code: addr_code ? addr_code.split(",") : [],
  729. cat_id: cat_id ? [cat_id[cat_id.length - 1]] : [],
  730. supplierNo: supplierNo ? [supplierNo] : [],
  731. khNo: khNo ? [khNo] : [],
  732. tax: tax ? tax + "%" : "",
  733. goodUnit: goodUnit ? [goodUnit] : ""
  734. };
  735. this.cat_id_name = cat_id.map(({ name }) => name).join("_");
  736. this.unit_name = unitName;
  737. this.khName = khName;
  738. this.supplierName = supplierNanme;
  739. this.detailLoading = false;
  740. },
  741. platform_codesearchChange(e) {
  742. const { id, label, pay_name } = e;
  743. this.ruleForm.platform_id = id || "";
  744. this.pay_name = pay_name || "";
  745. this.$refs.ruleForm.validateField("platform_id");
  746. },
  747. // async getAccounts() {
  748. // const res = await asyncRequest.accountall(this.dataForm);
  749. // if (res && res.code === 0 && res.data) {
  750. // this.accounts = res.data;
  751. // } else if (res && res.code >= 100 && res.code <= 104) {
  752. // await this.logout();
  753. // } else {
  754. // this.$message.warning(res.message);
  755. // }
  756. // },
  757. async goods_class_change(e) {
  758. const { id } = e;
  759. this.ruleForm.cat_id = id ? [id] : [];
  760. this.$refs.ruleForm.validateField("cat_id");
  761. },
  762. async submitForm() {
  763. console.log(111)
  764. await this.$refs.ruleForm.validate(async valid => {
  765. if (valid) {
  766. if (this.loading) {
  767. return;
  768. }
  769. this.loading = true;
  770. const model = JSON.parse(JSON.stringify(this.ruleForm));
  771. model.supplierNo = model.supplierNo[0];
  772. model.khNo = model.khNo[0];
  773. model.buyerid = Array.isArray(model.buyerid)
  774. ? model.buyerid[0]
  775. : model.buyerid;
  776. model.cat_id = model.cat_id
  777. ? model.cat_id[model.cat_id.length - 1]
  778. : "";
  779. model.addr_code = model.addr_code.join(",");
  780. model.tax = model.tax.split("%")[0];
  781. model.pay_name = this.pay_name;
  782. model.goodUnit = Array.isArray(model.goodUnit)
  783. ? model.goodUnit[0]
  784. : model.goodUnit;
  785. let res = {};
  786. if (this.id === "003") {
  787. delete model["id"];
  788. res = await asyncRequest.add(model);
  789. } else {
  790. res = await asyncRequest.update(model);
  791. }
  792. this.loading = false;
  793. if (res && res.code === 0) {
  794. const title = this.id === "003" ? "添加成功!" : "修改成功!";
  795. this.$notify.success({
  796. title,
  797. message: ""
  798. });
  799. this.showModelThis = false;
  800. // 刷新
  801. this.$emit("refresh");
  802. } else if (res && res.code >= 100 && res.code <= 104) {
  803. await this.logout();
  804. } else {
  805. this.$message.warning(res.message);
  806. }
  807. } else {
  808. console.log("error submit!!");
  809. return false;
  810. }
  811. });
  812. }
  813. }
  814. };
  815. </script>
  816. <style lang="scss" scoped>
  817. .terrace {
  818. }
  819. </style>