detailsPage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button
  7. type="danger"
  8. style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList"
  11. >返回列表
  12. </el-button>
  13. </div>
  14. <el-button type="success" class="copy-customer-btn" disabled>
  15. 复制新单
  16. </el-button>
  17. <el-button
  18. class="el-button--small-yh add-customer-btn"
  19. type="primary"
  20. :disabled="disabled"
  21. @click="editCustomer"
  22. >{{ form.id ? "确认修改" : "确认新增" }}
  23. </el-button>
  24. </div>
  25. <div style="margin-top: 60px;margin-bottom:35px">
  26. <containerTitle title="基础信息"></containerTitle>
  27. <basic-container style="margin-bottom: 10px">
  28. <avue-form ref="form" v-model="form" :option="option">
  29. <template slot="corpId">
  30. <select-component
  31. v-model="form.corpId"
  32. :configuration="configuration"
  33. :disabled="detailData.status == 1"
  34. ></select-component>
  35. </template>
  36. </avue-form>
  37. </basic-container>
  38. <containerTitle title="商品信息"></containerTitle>
  39. <basic-container>
  40. <avue-crud
  41. ref="crud"
  42. :data="data"
  43. :option="tableOption"
  44. @row-del="rowDel"
  45. @saveColumn="saveColumn"
  46. >
  47. <template slot="menuLeft">
  48. <el-button
  49. type="primary"
  50. icon="el-icon-plus"
  51. size="small"
  52. @click.stop="newDetails"
  53. :disabled="detailData.status == 1"
  54. >新增明细</el-button
  55. >
  56. <el-button
  57. type="info"
  58. icon="el-icon-printer"
  59. size="small"
  60. @click.stop="openReport()"
  61. >报 表</el-button
  62. >
  63. </template>
  64. <template slot="itemType" slot-scope="{ row }">
  65. <el-select
  66. v-if="row.$cellEdit"
  67. v-model="row.itemType"
  68. filterable
  69. allow-create
  70. default-first-option
  71. placeholder="请输入"
  72. @focus="itemTypeFocus(row)"
  73. >
  74. <el-option
  75. v-for="(item, index) in itemtypeList"
  76. :key="index"
  77. :label="item.value"
  78. :value="item.value"
  79. >
  80. </el-option>
  81. </el-select>
  82. <span v-else>{{ row.itemType }}</span>
  83. </template>
  84. <template slot="taxRate" slot-scope="{ row }">
  85. <el-input
  86. v-if="row.$cellEdit"
  87. size="mini"
  88. v-model="row.taxRate"
  89. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  90. @change="rateChange(row)"
  91. placeholder="请输入"
  92. />
  93. <span v-else>{{ row.taxRate }}</span>
  94. </template>
  95. <template slot="menu" slot-scope="{ row, index }">
  96. <el-button
  97. size="small"
  98. icon="el-icon-edit"
  99. type="text"
  100. @click="rowCell(row, index)"
  101. :disabled="disabled"
  102. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  103. >
  104. <el-button
  105. size="small"
  106. icon="el-icon-edit"
  107. type="text"
  108. @click="rowDel(row, index)"
  109. >删 除</el-button
  110. >
  111. </template>
  112. <template slot="price" slot-scope="{ row }">
  113. <el-input
  114. v-if="row.$cellEdit"
  115. v-model="row.price"
  116. size="small"
  117. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  118. @change="priceChange(row)"
  119. ></el-input>
  120. <span v-else>{{ row.price }}</span>
  121. </template>
  122. <template slot="actualQuantity" slot-scope="{ row }">
  123. <el-input
  124. v-if="row.$cellEdit"
  125. v-model="row.actualQuantity"
  126. size="small"
  127. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  128. @change="quantityChange(row)"
  129. ></el-input>
  130. <span v-else>{{ row.actualQuantity }}</span>
  131. </template>
  132. </avue-crud>
  133. </basic-container>
  134. <fee-info
  135. ref="feeInfo"
  136. :orderFeesList="orderFeesList"
  137. :disabled="detailData.status == 1"
  138. feeUrl="/blade-deliver-goods/deliveryfees/update"
  139. />
  140. <upload-file
  141. ref="uploadFile"
  142. title="合同附件"
  143. :orderFilesList="orderFilesList"
  144. :disabled="detailData.status == 1"
  145. delUrl="/blade-deliver-goods/deliveryfiles/update"
  146. />
  147. </div>
  148. <el-dialog
  149. title="导入商品"
  150. append-to-body
  151. class="el-dialogDeep"
  152. :visible.sync="dialogVisible"
  153. width="60%"
  154. :close-on-click-modal="false"
  155. :destroy-on-close="true"
  156. :close-on-press-escape="false"
  157. @close="closeGoods"
  158. top="10vh"
  159. >
  160. <span>
  161. <el-row>
  162. <el-col :span="5">
  163. <div>
  164. <el-scrollbar>
  165. <basic-container style="margin-top:45px">
  166. <avue-tree :option="treeOption" @node-click="nodeClick" />
  167. </basic-container>
  168. </el-scrollbar>
  169. </div>
  170. </el-col>
  171. <el-col :span="19">
  172. <avue-crud
  173. :option="goodsOption"
  174. :table-loading="loading"
  175. :data="goodsList"
  176. ref="goodsCrud"
  177. @refresh-change="refreshChange"
  178. @selection-change="selectionChange"
  179. @row-click="rowClick"
  180. :page.sync="page"
  181. @on-load="onLoad"
  182. ></avue-crud>
  183. </el-col>
  184. </el-row>
  185. </span>
  186. <span slot="footer" class="dialog-footer">
  187. <el-button @click="dialogVisible = false">取 消</el-button>
  188. <el-button
  189. type="primary"
  190. @click="importGoods"
  191. :disabled="selectionList.length == 0"
  192. >导入</el-button
  193. >
  194. </span>
  195. </el-dialog>
  196. <report-dialog
  197. :switchDialog="switchDialog"
  198. :reportId="form.id"
  199. reportName="客户询价"
  200. @onClose="onClose()"
  201. ></report-dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import tableOption from "./config/customerContact.json";
  206. import goodsOption from "./config/commodity.json";
  207. import feeInfo from "@/components/fee-info/main";
  208. import {
  209. detail,
  210. submit,
  211. delItem,
  212. getDeptLazyTree,
  213. getGoods,
  214. getSpecification
  215. } from "@/api/basicData/invoice";
  216. import uploadFile from "@/components/upload-file/main";
  217. import reportDialog from "@/components/report-dialog/main";
  218. import { isvalidatemobile, validatename } from "@/util/validate";
  219. import _ from "lodash";
  220. export default {
  221. name: "detailsPageEdit",
  222. data() {
  223. const validatePhone = (rule, value, callback) => {
  224. if (value != "") {
  225. if (isvalidatemobile(value)[0]) {
  226. this.$message.error("手机号码格式不正确");
  227. callback(new Error(isvalidatemobile(value)[1]));
  228. } else {
  229. callback();
  230. }
  231. } else {
  232. callback();
  233. }
  234. };
  235. const validateName = (rule, value, callback) => {
  236. if (value != "") {
  237. if (validatename(value)) {
  238. this.$message.error("联系人格式不正确");
  239. callback(new Error(validatename(value)));
  240. } else {
  241. callback();
  242. }
  243. } else {
  244. callback();
  245. }
  246. };
  247. return {
  248. configuration: {
  249. multipleChoices: false,
  250. multiple: false,
  251. collapseTags: false,
  252. placeholder: "请点击右边按钮选择",
  253. dicData: []
  254. },
  255. switchDialog: false,
  256. form: {},
  257. disabled: false,
  258. dialogVisible: false,
  259. tableOption: {},
  260. option: {
  261. menuBtn: false,
  262. labelWidth: 100,
  263. column: [
  264. {
  265. label: "客户名称",
  266. prop: "corpId",
  267. rules: [
  268. {
  269. required: true,
  270. message: "",
  271. trigger: "blur"
  272. }
  273. ],
  274. span: 8,
  275. slot: true
  276. },
  277. {
  278. label: "系统号",
  279. prop: "sysNo",
  280. span: 8
  281. },
  282. {
  283. label: "销售订单号",
  284. prop: "orderNo",
  285. span: 8
  286. },
  287. {
  288. label: "订单状态",
  289. prop: "deliveryStatus",
  290. span: 8
  291. },
  292. {
  293. label: "仓库名称",
  294. prop: "storageId",
  295. span: 8
  296. },
  297. {
  298. label: "仓库类型",
  299. prop: "warehouseType",
  300. span: 8
  301. },
  302. {
  303. label: "发货日期",
  304. prop: "businessDate",
  305. span: 8,
  306. type: "date",
  307. format: "yyyy-MM-dd",
  308. valueFormat: "yyyy-MM-dd 00:00:00"
  309. },
  310. {
  311. label: "出库金额",
  312. prop: "deliveryAmount",
  313. span: 8
  314. },
  315. {
  316. label: "出库数量",
  317. prop: "totalQuantity",
  318. span: 8
  319. },
  320. {
  321. label: "费用合计",
  322. prop: "totalCost",
  323. span: 8
  324. },
  325. {
  326. label: "收货地址",
  327. prop: "arrivalAddress",
  328. span: 8
  329. },
  330. {
  331. label: "联系人",
  332. prop: "arrivalContact",
  333. span: 8,
  334. rules: [{ validator: validateName, trigger: "blur" }]
  335. },
  336. {
  337. label: "电话",
  338. prop: "arrivalTel",
  339. span: 8,
  340. rules: [{ validator: validatePhone, trigger: "blur" }]
  341. },
  342. {
  343. label: "制单时间",
  344. prop: "createTime",
  345. span: 8,
  346. type: "date",
  347. format: "yyyy-MM-dd",
  348. valueFormat: "yyyy-MM-dd 00:00:00",
  349. disabled: true
  350. },
  351. {
  352. label: "备注",
  353. prop: "deliveryRemarks",
  354. type: "textarea",
  355. minRows: 2,
  356. span: 8
  357. }
  358. ]
  359. },
  360. treeOption: {
  361. nodeKey: "id",
  362. lazy: true,
  363. treeLoad: function(node, resolve) {
  364. const parentId = node.level === 0 ? 0 : node.data.id;
  365. getDeptLazyTree(parentId).then(res => {
  366. resolve(
  367. res.data.data.map(item => {
  368. return {
  369. ...item,
  370. leaf: !item.hasChildren
  371. };
  372. })
  373. );
  374. });
  375. },
  376. addBtn: false,
  377. menu: false,
  378. size: "small",
  379. props: {
  380. label: "title",
  381. value: "value",
  382. children: "children"
  383. }
  384. },
  385. page: {
  386. pageSize: 10,
  387. currentPage: 1,
  388. total: 0
  389. },
  390. loading: false,
  391. goodsOption: goodsOption,
  392. data: [],
  393. goodsList: [],
  394. selectionList: [],
  395. treeDeptId: null,
  396. orderFeesList: [],
  397. orderFilesList: [],
  398. itemtypeList: []
  399. };
  400. },
  401. props: {
  402. detailData: {
  403. type: Object
  404. }
  405. },
  406. components: {
  407. reportDialog,
  408. feeInfo,
  409. uploadFile
  410. },
  411. async created() {
  412. this.tableOption = await this.getColumnData(
  413. this.getColumnName(9),
  414. tableOption
  415. );
  416. if (this.$route.query.pageType == "Generate") {
  417. this.getGenerate(JSON.parse(this.$route.query.data));
  418. }
  419. if (this.detailData.id) {
  420. this.getDetail(this.detailData.id);
  421. }
  422. if (this.detailData.status == 1) {
  423. this.option.disabled = true;
  424. }
  425. let _this = this;
  426. this.tableOption.column.forEach(e => {
  427. if (e.prop == "taxRate") {
  428. e.formatter = function(row) {
  429. return _this.textFormat(
  430. Number(row.taxRate ? row.taxRate : 0) / 100,
  431. "0.00%"
  432. );
  433. };
  434. }
  435. if (e.prop == "contractAmount" || e.prop == "price") {
  436. e.formatter = function(row) {
  437. return _this.textFormat(
  438. Number(row.contractAmount ? row.contractAmount : 0),
  439. "#,##0.00"
  440. );
  441. };
  442. }
  443. });
  444. },
  445. methods: {
  446. itemTypeFocus(row) {
  447. this.itemtypeList = [];
  448. getSpecification({ goodId: row.itemId }).then(res => {
  449. const data = res.data.data;
  450. this.itemtypeList = data.map(item => ({ value: item }));
  451. });
  452. },
  453. //编辑
  454. rowCell(row, index) {
  455. if (row.$cellEdit == true) {
  456. this.$set(row, "$cellEdit", false);
  457. } else {
  458. this.$set(row, "$cellEdit", true);
  459. }
  460. },
  461. priceChange(row) {
  462. console.log(row);
  463. if (!row.price) {
  464. row.price = 0;
  465. } else {
  466. row.contractAmount = _.multiply(row.price, row.actualQuantity).toFixed(
  467. 2
  468. );
  469. }
  470. },
  471. quantityChange(row) {
  472. if (!row.actualQuantity) {
  473. row.actualQuantity = 0;
  474. } else {
  475. row.contractAmount = _.multiply(row.price, row.actualQuantity).toFixed(
  476. 2
  477. );
  478. }
  479. },
  480. rateChange(row) {
  481. if (row >= 100) {
  482. row.taxRate = 0;
  483. this.$message.error("汇率不能超过100%");
  484. }
  485. },
  486. rowSave(row) {
  487. console.log(row);
  488. this.$set(row, "$cellEdit", false);
  489. },
  490. rowDel(row, index) {
  491. this.$confirm("确定删除数据?", {
  492. confirmButtonText: "确定",
  493. cancelButtonText: "取消",
  494. type: "warning"
  495. }).then(() => {
  496. if (row.id) {
  497. delItem(row.id).then(res => {
  498. this.$message({
  499. type: "success",
  500. message: "删除成功!"
  501. });
  502. this.data.splice(index, 1);
  503. });
  504. } else {
  505. this.$message({
  506. type: "success",
  507. message: "删除成功!"
  508. });
  509. this.data.splice(index, 1);
  510. }
  511. });
  512. },
  513. importGoods() {
  514. this.selectionList.forEach(e => {
  515. this.data.push({
  516. itemId: e.id,
  517. code: e.code,
  518. cname: e.cname,
  519. priceCategory: e.goodsTypeName,
  520. itemUrl: e.url,
  521. itemProp: null,
  522. itemDescription: null,
  523. itemType: null,
  524. actualQuantity: 0,
  525. tradeTerms: null,
  526. price: 0,
  527. contractAmount: 0,
  528. taxRate: 0,
  529. unit: e.unit,
  530. remarks: null,
  531. $cellEdit: true
  532. });
  533. });
  534. this.dialogVisible = false;
  535. },
  536. closeGoods() {
  537. this.selectionList = [];
  538. this.treeDeptId = "";
  539. },
  540. selectionChange(list) {
  541. this.selectionList = list;
  542. },
  543. rowClick(row) {
  544. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  545. },
  546. nodeClick(data) {
  547. this.treeDeptId = data.id;
  548. this.page.currentPage = 1;
  549. this.onLoad(this.page);
  550. },
  551. //费用查询
  552. onLoad(page, params = {}) {
  553. this.loading = true;
  554. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  555. const data = res.data.data;
  556. this.page.total = data.total;
  557. this.goodsList = data.records;
  558. this.loading = false;
  559. if (this.page.total) {
  560. this.goodsOption.height = window.innerHeight - 550;
  561. } else {
  562. this.goodsOption.height = window.innerHeight - 475;
  563. }
  564. });
  565. },
  566. //商品明细导入
  567. newDetails() {
  568. this.dialogVisible = !this.dialogVisible;
  569. },
  570. getDetail(id) {
  571. detail(id).then(res => {
  572. this.form = res.data.data;
  573. this.data = res.data.data.deliveryItemsList;
  574. this.orderFeesList = res.data.data.deliveryFeesList;
  575. this.orderFilesList = res.data.data.deliveryFilesList;
  576. this.configuration.dicData = this.form.corpName;
  577. });
  578. },
  579. getGenerate(data) {
  580. this.form = data;
  581. this.data = data.orderItemsList;
  582. this.orderFeesList = data.deliveryFeesList;
  583. this.configuration.dicData = data.corpName;
  584. },
  585. //修改提交触发
  586. editCustomer() {
  587. this.$refs["form"].validate((valid, done) => {
  588. done();
  589. if (valid) {
  590. let orderFeesList = this.$refs.feeInfo.submitData();
  591. for (let i = 0; i < orderFeesList.length; i++) {
  592. if (orderFeesList[i].corpId == null) {
  593. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  594. }
  595. if (orderFeesList[i].price == 0) {
  596. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  597. }
  598. if (orderFeesList[i].actualQuantity == 0) {
  599. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  600. }
  601. }
  602. const orderFilesList = this.$refs.uploadFile.submitData();
  603. submit({
  604. ...this.form,
  605. deliveryItemsList: this.data,
  606. deliveryFeesList: orderFeesList,
  607. deliveryFilesList: orderFilesList
  608. }).then(res => {
  609. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  610. this.form = res.data.data;
  611. this.data = res.data.data.deliveryItemsList;
  612. this.orderFeesList = res.data.data.deliveryFeesList;
  613. this.orderFilesList = res.data.data.deliveryFilesList;
  614. });
  615. } else {
  616. return false;
  617. }
  618. });
  619. },
  620. //返回列表
  621. backToList() {
  622. this.$emit("goBack");
  623. },
  624. openReport() {
  625. this.switchDialog = !this.switchDialog;
  626. },
  627. onClose(val) {
  628. this.switchDialog = val;
  629. },
  630. async saveColumn() {
  631. const inSave = await this.saveColumnData(
  632. this.getColumnName(9),
  633. this.tableOption
  634. );
  635. if (inSave) {
  636. this.$message.success("保存成功");
  637. //关闭窗口
  638. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  639. }
  640. }
  641. }
  642. };
  643. </script>
  644. <style lang="scss" scoped>
  645. .customer-head {
  646. position: fixed;
  647. top: 105px;
  648. width: 100%;
  649. margin-left: -10px;
  650. height: 62px;
  651. background: #ffffff;
  652. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  653. z-index: 999;
  654. }
  655. .customer-back {
  656. cursor: pointer;
  657. line-height: 62px;
  658. font-size: 16px;
  659. color: #323233;
  660. font-weight: 400;
  661. }
  662. .back-icon {
  663. line-height: 64px;
  664. font-size: 20px;
  665. margin-right: 8px;
  666. }
  667. .copy-customer-btn {
  668. position: fixed;
  669. right: 140px;
  670. top: 115px;
  671. }
  672. .add-customer-btn {
  673. position: fixed;
  674. right: 36px;
  675. top: 115px;
  676. }
  677. ::v-deep .el-form-item {
  678. margin-bottom: 8px;
  679. }
  680. ::v-deep .el-form-item__error {
  681. display: none;
  682. }
  683. ::v-deep .select-component {
  684. display: flex;
  685. }
  686. </style>