addEdit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="title"
  5. :center="true"
  6. align="left"
  7. top="5vh"
  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="closeModel"
  15. >
  16. <el-card style="margin-top: -20px">
  17. <el-form
  18. ref="ruleForm"
  19. :model="ruleForm"
  20. status-icon
  21. :rules="rulesThis"
  22. size="mini"
  23. label-width="93px"
  24. class="demo-ruleForm"
  25. >
  26. <el-row :gutter="10">
  27. <el-col :span="24" style="padding: 0 0 10px 0; margin-top: -5px">
  28. <el-divider><el-tag size="mini">确认单信息</el-tag></el-divider>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="创建人" prop="sale_name">
  32. <el-input
  33. v-model.trim="ruleForm.sale_name"
  34. placeholder="请输入创建人"
  35. :disabled="isDetail"
  36. maxlength="200"
  37. /> </el-form-item
  38. ></el-col>
  39. <el-col :span="6">
  40. <el-form-item label="部门" prop="department">
  41. <el-input
  42. v-model.trim="ruleForm.department"
  43. placeholder="请输入部门"
  44. disabled
  45. maxlength="200"
  46. /> </el-form-item
  47. ></el-col>
  48. <el-col :span="6">
  49. <el-form-item label="确认单类型" prop="qrdType">
  50. <el-input
  51. v-model.trim="ruleForm.qrdType"
  52. placeholder="请输入确认单类型"
  53. disabled
  54. maxlength="200"
  55. /> </el-form-item
  56. ></el-col>
  57. <el-col :span="6">
  58. <el-form-item label="采购毛利率" prop="cgd_tax">
  59. <el-input-number
  60. style="width: 100%"
  61. v-model="ruleForm.cgd_tax"
  62. controls-position="right"
  63. placeholder="请输入采购毛利率"
  64. :disabled="isDetail"
  65. :min="0"
  66. :precision="2"
  67. @change="numBlur"
  68. step-strictly
  69. :step="0.01"
  70. :max="100"
  71. ></el-input-number> </el-form-item
  72. ></el-col>
  73. <el-col :span="12">
  74. <el-form-item label="单据号" prop="a5">
  75. <el-input
  76. v-model.trim="ruleForm.a5"
  77. placeholder="请输入单据号"
  78. :disabled="isDetail"
  79. maxlength="200"
  80. />
  81. </el-form-item> </el-col
  82. ><el-col :span="12">
  83. <el-form-item label="PO编号" prop="poNo">
  84. <el-input
  85. v-model.trim="ruleForm.poNo"
  86. placeholder="请输入PO编号"
  87. :disabled="isDetail"
  88. maxlength="200"
  89. />
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="12">
  93. <el-form-item label="购买方公司" prop="khNo">
  94. <search-select
  95. :code="ruleForm.khNo"
  96. :placeholder="'请选择购买方公司'"
  97. @end="searchChange1"
  98. :names="searchName1"
  99. :is-detail="id !== 'add'"
  100. :type="'1'"
  101. :size="'mini'"
  102. :disabled="isDetail"
  103. />
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-form-item label="销售方公司" prop="companyNo">
  108. <search-select
  109. :code="ruleForm.companyNo"
  110. :placeholder="'请选择销售方公司'"
  111. @end="searchChange2"
  112. :names="searchName2"
  113. :type="'2'"
  114. :size="'mini'"
  115. :is-detail="id !== 'add'"
  116. :disabled="isDetail"
  117. />
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="24" style="padding: 0 0 10px 0; margin-top: -5px">
  121. <el-divider><el-tag size="mini">收货信息</el-tag></el-divider>
  122. </el-col>
  123. <el-col :span="12">
  124. <el-form-item label="收货人" prop="contactor">
  125. <el-input
  126. v-model.trim="ruleForm.contactor"
  127. placeholder="请输入收货人"
  128. maxlength="200"
  129. :disabled="isDetail"
  130. />
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="12">
  134. <el-form-item label="联系电话" prop="mobile">
  135. <el-input
  136. v-model.trim="ruleForm.mobile"
  137. placeholder="请输入联系电话"
  138. maxlength="200"
  139. :disabled="isDetail"
  140. />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="12">
  144. <el-form-item label="联系地址" prop="addr">
  145. <el-input
  146. v-model.trim="ruleForm.addr"
  147. placeholder="请输入联系地址"
  148. maxlength="200"
  149. :disabled="isDetail"
  150. />
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="12">
  154. <el-form-item label="发货时间" prop="sendtime">
  155. <el-date-picker
  156. v-model="ruleForm.sendtime"
  157. :editable="false"
  158. :clearable="true"
  159. :size="'mini'"
  160. :picker-options="pickerOptions"
  161. placeholder="请选择发货时间"
  162. style="width: 100%; margin: 0"
  163. type="datetime"
  164. :disabled="isDetail"
  165. value-format="yyyy-MM-dd HH:mm:ss"
  166. >
  167. </el-date-picker>
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="24" style="padding: 0 0 10px 0; margin-top: -5px">
  171. <el-divider><el-tag size="mini">商品信息</el-tag></el-divider>
  172. </el-col>
  173. <el-col :span="12">
  174. <el-form-item label="供应商公司" prop="supplierNo">
  175. <search-select
  176. :code="ruleForm.supplierNo"
  177. :placeholder="'请选择供应商公司'"
  178. @end="searchChange3"
  179. :type="'3'"
  180. :size="'mini'"
  181. :names="searchName3"
  182. :disabled="isDetail"
  183. :is-detail="id !== 'add'"
  184. /> </el-form-item
  185. ></el-col>
  186. <el-col :span="12">
  187. <el-form-item label="商品名称" prop="goodName">
  188. <el-input
  189. v-model.trim="ruleForm.goodName"
  190. placeholder="请输入商品名称"
  191. maxlength="200"
  192. :disabled="isDetail"
  193. /> </el-form-item
  194. ></el-col>
  195. <el-col :span="6">
  196. <el-form-item label="数量" prop="goodNum">
  197. <el-input-number
  198. style="width: 100%"
  199. v-model="ruleForm.goodNum"
  200. controls-position="right"
  201. placeholder="请输入数量"
  202. :disabled="isDetail"
  203. :min="0"
  204. :precision="0"
  205. @change="numBlur"
  206. step-strictly
  207. :step="1"
  208. :max="9999999"
  209. ></el-input-number> </el-form-item
  210. ></el-col>
  211. <el-col :span="6">
  212. <el-form-item label="单价" label-width="55px" prop="goodPice">
  213. <el-input-number
  214. v-model="ruleForm.goodPice"
  215. controls-position="right"
  216. placeholder="请输入单价"
  217. style="width: 100%"
  218. :disabled="isDetail"
  219. :min="0"
  220. :precision="2"
  221. @change="numBlur"
  222. step-strictly
  223. :step="0.01"
  224. :max="9999999"
  225. ></el-input-number>
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="6">
  229. <el-form-item label="货款总额" prop="good_total">
  230. <el-input
  231. v-model.number="ruleForm.good_total"
  232. placeholder="请输入货款总额"
  233. disabled
  234. ><template slot="append">元</template></el-input
  235. >
  236. </el-form-item></el-col
  237. >
  238. <el-col :span="6">
  239. <el-form-item label="税率" prop="tax">
  240. <search-select
  241. :code="ruleForm.tax"
  242. :placeholder="'请选择税率'"
  243. @end="searchChange4"
  244. :type="'4'"
  245. :size="'mini'"
  246. :names="searchName4"
  247. :disabled="isDetail"
  248. :is-detail="id !== 'add'"
  249. />
  250. </el-form-item>
  251. </el-col>
  252. </el-row>
  253. </el-form>
  254. <el-row>
  255. <el-col :span="24" style="text-align: right">
  256. <el-button v-if="!isDetail" type="primary" @click="submitForm"
  257. >保 存
  258. </el-button>
  259. <el-button @click="showModelThis = false">{{
  260. isDetail ? "关 闭" : "取 消"
  261. }}</el-button>
  262. </el-col>
  263. </el-row>
  264. </el-card>
  265. </el-dialog>
  266. </template>
  267. <script>
  268. import asyncRequest from "@/apis/service/network/orderEntry";
  269. import resToken from "@/mixins/resToken";
  270. import { isMobile, isPhone } from "@/utils/validate";
  271. export default {
  272. name: "Account",
  273. props: ["showModel", "id", "isDetail"],
  274. mixins: [resToken],
  275. data() {
  276. const validatemobile = (rule, value, callback) => {
  277. if (value !== "") {
  278. if (isPhone(value) || isMobile(value)) {
  279. callback();
  280. } else {
  281. callback(new Error("联系电话格式不正确!"));
  282. }
  283. } else {
  284. callback(new Error("请输入联系电话!"));
  285. }
  286. };
  287. return {
  288. searchName1: "",
  289. searchName2: "",
  290. searchName3: "",
  291. searchName4: "",
  292. company_img: "",
  293. bm: "",
  294. roleList: [],
  295. loading: false,
  296. title: "添加确认单信息",
  297. showModelThis: this.showModel,
  298. ruleForm: {},
  299. rulesThis: this.rules,
  300. pickerOptions: {
  301. disabledDate: (time) => {
  302. return time.getTime() > new Date().valueOf();
  303. },
  304. },
  305. // validator: validateLicense,
  306. rules: {
  307. sale_name: [
  308. {
  309. required: true,
  310. message: "请输入创建人",
  311. trigger: "blur",
  312. },
  313. ],
  314. department: [
  315. {
  316. required: true,
  317. message: "请输入部门",
  318. trigger: "blur",
  319. },
  320. ],
  321. cgd_tax: [
  322. {
  323. required: true,
  324. message: "请输入采购毛利率",
  325. trigger: "blur",
  326. },
  327. ],
  328. supplierNo: [
  329. {
  330. type: "array",
  331. required: true,
  332. message: "请选择供应商公司",
  333. trigger: "change",
  334. },
  335. ],
  336. qrdType: [
  337. {
  338. required: true,
  339. message: "请输入订单类型",
  340. trigger: "blur",
  341. },
  342. ],
  343. good_total: [
  344. {
  345. required: true,
  346. message: "请输入货款总金额",
  347. trigger: "blur",
  348. },
  349. ],
  350. a5: [
  351. {
  352. required: true,
  353. message: "请输入单据号",
  354. trigger: "blur",
  355. },
  356. ],
  357. poNo: [
  358. {
  359. required: true,
  360. message: "请输入PO编号",
  361. trigger: "blur",
  362. },
  363. ],
  364. khNo: [
  365. {
  366. type: "array",
  367. required: true,
  368. message: "请选择购买方公司",
  369. trigger: "change",
  370. },
  371. ],
  372. tax: [
  373. {
  374. type: "array",
  375. required: true,
  376. message: "请选择税率",
  377. trigger: "change",
  378. },
  379. ],
  380. companyNo: [
  381. {
  382. type: "array",
  383. required: true,
  384. message: "请选择销售方公司",
  385. trigger: "change",
  386. },
  387. ],
  388. contactor: [
  389. {
  390. required: true,
  391. message: "请输入收货人",
  392. trigger: "blur",
  393. },
  394. ],
  395. mobile: [
  396. {
  397. required: true,
  398. validator: validatemobile,
  399. trigger: "blur",
  400. },
  401. ],
  402. addr: [
  403. {
  404. required: true,
  405. message: "请输入联系地址",
  406. trigger: "blur",
  407. },
  408. ],
  409. sendtime: [
  410. {
  411. required: true,
  412. message: "请输入发货时间",
  413. trigger: "change",
  414. },
  415. ],
  416. goodName: [
  417. {
  418. required: true,
  419. message: "请输入商品名称",
  420. trigger: "blur",
  421. },
  422. ],
  423. goodPice: [
  424. {
  425. required: true,
  426. message: "请输入单价",
  427. trigger: "blur",
  428. },
  429. ],
  430. goodNum: [
  431. {
  432. required: true,
  433. message: "请输入数量",
  434. trigger: "blur",
  435. },
  436. ],
  437. },
  438. };
  439. },
  440. watch: {
  441. showModel: function (val) {
  442. this.showModelThis = val;
  443. if (val) {
  444. this.initForm();
  445. }
  446. },
  447. showModelThis(val) {
  448. if (!val) {
  449. this.$emit("cancel");
  450. }
  451. },
  452. },
  453. methods: {
  454. closeModel() {
  455. console.log("closeModel!!");
  456. },
  457. searchChange1(e) {
  458. this.ruleForm.khNo = JSON.parse(JSON.stringify(e));
  459. this.$refs.ruleForm.validateField("khNo");
  460. console.log(this.ruleForm.khNo);
  461. },
  462. searchChange2(e) {
  463. this.ruleForm.companyNo = JSON.parse(JSON.stringify(e));
  464. this.$refs.ruleForm.validateField("companyNo");
  465. },
  466. searchChange3(e) {
  467. this.ruleForm.supplierNo = JSON.parse(JSON.stringify(e));
  468. this.$refs.ruleForm.validateField("supplierNo");
  469. },
  470. searchChange4(e) {
  471. this.ruleForm.tax = JSON.parse(JSON.stringify(e));
  472. this.$refs.ruleForm.validateField("tax");
  473. },
  474. async initForm() {
  475. this.setform();
  476. this.searchName1 = "";
  477. this.searchName2 = "";
  478. this.searchName3 = "";
  479. this.searchName4 = "";
  480. this.loading = true;
  481. if (this.id === "add") {
  482. this.title = "添加确认单信息";
  483. this.rulesThis = this.rules;
  484. await this.resetForm();
  485. } else {
  486. if (this.isDetail) {
  487. this.title = "确认单信息详情";
  488. this.rulesThis = {};
  489. } else {
  490. this.title = "修改确认单信息";
  491. this.rulesThis = this.rules;
  492. }
  493. await this.resetForm();
  494. await this.initData();
  495. }
  496. this.loading = false;
  497. },
  498. async initData() {
  499. //KH202104272612 泰康人寿云南分公司玉溪中支
  500. //CMP20210608140627719 北京万宇恒通国际科贸有限公司
  501. //GYS-20210416-0316 北京顺捷玖芊科技有限公司
  502. this.searchName1 = "泰康人寿云南分公司玉溪中支";
  503. this.searchName2 = "北京万宇恒通国际科贸有限公司";
  504. this.searchName3 = "北京顺捷玖芊科技有限公司";
  505. this.searchName4 = "13";
  506. this.ruleForm = {
  507. khNo: ["KH202104272612"],
  508. companyNo: ["CMP20210608140627719"],
  509. supplierNo: ["GYS-20210416-0316"],
  510. sale_name: "张三",
  511. department: "网络部",
  512. qrdType: "客服确认单",
  513. good_total: 0,
  514. a5: "xxxxxx",
  515. poNo: "yyyyyy",
  516. contactor: "李四",
  517. mobile: "17744520491",
  518. addr: "北京市东城区",
  519. sendtime: "",
  520. goodName: "商品名称",
  521. goodPice: 0,
  522. goodNum: 0,
  523. cgd_tax: 0,
  524. tax: [],
  525. };
  526. // const res = await asyncRequest.detail({ companyNo: this.id });
  527. // if (res && res.code === 0) {
  528. // // this.ruleForm = res.data;
  529. // // this.ruleForm.companyNo = this.id;
  530. // } else if (res && res.code >= 100 && res.code <= 104) {
  531. // await this.logout();
  532. // } else {
  533. // this.$message.warning(res.message);
  534. // }
  535. },
  536. async resetForm() {
  537. // 重置
  538. await this.$nextTick(() => {
  539. if (this.$refs.ruleForm) {
  540. this.$refs.ruleForm.resetFields();
  541. this.$refs.ruleForm.clearValidate();
  542. this.setform();
  543. }
  544. });
  545. },
  546. setform() {
  547. this.ruleForm = {
  548. khNo: [],
  549. companyNo: [],
  550. supplierNo: [],
  551. sale_name: "张三",
  552. department: "网络部",
  553. qrdType: "客服确认单",
  554. good_total: 0,
  555. a5: "xxxxxx",
  556. poNo: "yyyyyy",
  557. contactor: "李四",
  558. mobile: "17744520491",
  559. addr: "北京市东城区",
  560. sendtime: "",
  561. goodName: "商品名称",
  562. goodPice: 0,
  563. goodNum: 0,
  564. cgd_tax: 0,
  565. tax: [],
  566. };
  567. },
  568. numBlur() {
  569. this.ruleForm.good_total = this.setNum(
  570. this.ruleForm.goodPice * 1 * (this.ruleForm.goodNum * 1)
  571. );
  572. },
  573. setNum(s) {
  574. return s ? parseFloat(s + "").toFixed(2) : "0";
  575. },
  576. async submitForm() {
  577. await this.$refs.ruleForm.validate(async (valid) => {
  578. if (valid) {
  579. this.loading = true;
  580. const obj = JSON.parse(JSON.stringify(this.ruleForm));
  581. if (parseFloat(obj.goodPice + "").toFixed(2) === "0.00") {
  582. this.$message.warning("商品单价不能为0!");
  583. this.loading = false;
  584. return;
  585. }
  586. if (obj.goodNum === 0) {
  587. this.$message.warning("商品数量不能为0!");
  588. this.loading = false;
  589. return;
  590. }
  591. obj.companyNo = obj.companyNo[0];
  592. obj.khNo = obj.khNo[0];
  593. obj.supplierNo = obj.supplierNo[0];
  594. obj.tax = obj.tax[0];
  595. obj.buyer = obj.sale_name;
  596. obj.buy_depart = obj.department;
  597. let res = {};
  598. if (this.id === "add") {
  599. delete obj["id"];
  600. res = await asyncRequest.add(obj);
  601. } else {
  602. res = await asyncRequest.update(obj);
  603. }
  604. this.loading = false;
  605. if (res && res.code === 0) {
  606. const title = this.id === "add" ? "添加成功!" : "修改成功!";
  607. this.$notify.success({
  608. title,
  609. message: "",
  610. });
  611. this.showModelThis = false;
  612. // 刷新
  613. this.$emit("refresh");
  614. } else if (res && res.code >= 100 && res.code <= 104) {
  615. await this.logout();
  616. } else {
  617. this.$message.warning(res.message);
  618. }
  619. } else {
  620. console.log("error submit!!");
  621. return false;
  622. }
  623. });
  624. },
  625. },
  626. };
  627. </script>
  628. <style lang="scss" scoped>
  629. .finance {
  630. .activity-upload {
  631. .btnupload {
  632. float: left;
  633. border: 1px solid #cccccc;
  634. box-sizing: border-box;
  635. width: 135px;
  636. height: 135px;
  637. line-height: 135px;
  638. text-align: center;
  639. }
  640. .Upload {
  641. width: 135px;
  642. height: 135px;
  643. line-height: 135px;
  644. text-align: center;
  645. position: absolute;
  646. line-height: 0px;
  647. top: 0;
  648. left: 0;
  649. line-height: 135px;
  650. }
  651. .fileUp {
  652. vertical-align: top;
  653. }
  654. .avatar {
  655. width: 135px;
  656. height: 135px;
  657. line-height: 135px;
  658. text-align: center;
  659. }
  660. .avatar-uploader .el-upload:hover {
  661. border-color: #409eff;
  662. }
  663. .avatar-uploader-icon {
  664. font-size: 28px;
  665. color: #8c939d;
  666. width: 50px;
  667. height: 50px;
  668. line-height: 50px;
  669. text-align: center;
  670. }
  671. .avatar {
  672. width: 100%;
  673. height: 100%;
  674. display: block;
  675. }
  676. .txt-tips {
  677. display: inline-block;
  678. font-size: 13px;
  679. color: #606266;
  680. padding: 18px 0 0 18px;
  681. p {
  682. margin: 0;
  683. line-height: 30px;
  684. }
  685. }
  686. .avatar-uploader .el-upload {
  687. border: 1px dashed #d9d9d9;
  688. border-radius: 6px;
  689. cursor: pointer;
  690. position: relative;
  691. overflow: hidden;
  692. }
  693. }
  694. }
  695. </style>