detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. >返回列表</el-button>
  11. </div>
  12. <div class="add-customer-btn">
  13. <el-button
  14. type="primary"
  15. size="small"
  16. class="el-button--small-yh"
  17. @click.stop="openEdit"
  18. >编 辑</el-button>
  19. <el-button
  20. type="success"
  21. :disabled="!form.id"
  22. size="small"
  23. @click="copyDoc"
  24. >
  25. 复制单据
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. @click="editCustomer"
  30. size="small"
  31. >保存数据
  32. </el-button>
  33. </div>
  34. </div>
  35. <div class="customer-main">
  36. <containerTitle title="基础信息"/>
  37. <basic-container :showBtn="true">
  38. <avue-form
  39. ref="form"
  40. class="trading-form"
  41. v-model="form"
  42. :option="option"
  43. >
  44. <template slot="corpId">
  45. <crop-select
  46. v-model="form.corpId"
  47. @getCorpData="getCorpData"
  48. corpType="KH"
  49. ></crop-select>
  50. </template>
  51. <template slot="storageId">
  52. <warehouse-select
  53. v-model="form.storageId"
  54. :configuration="configurationWarehouse"/>
  55. </template>
  56. </avue-form>
  57. </basic-container>
  58. <containerTitle title="商品信息"/>
  59. <basic-container>
  60. <avue-crud
  61. ref="crud"
  62. :data="dataList"
  63. :option="tableOption"
  64. :cell-style="cellStyle"
  65. @saveColumn="saveColumn"
  66. @resetColumn="resetColumn"
  67. >
  68. <template slot="menuLeft">
  69. <el-button
  70. type="primary"
  71. icon="el-icon-plus"
  72. size="small"
  73. @click.stop="newDetails"
  74. >录入明细</el-button>
  75. <el-button
  76. type="info"
  77. icon="el-icon-printer"
  78. size="small"
  79. @click.stop="openReport()"
  80. >报 表</el-button
  81. >
  82. </template>
  83. <template slot="menu" slot-scope="{ row, index }">
  84. <el-button
  85. size="small"
  86. icon="el-icon-edit"
  87. type="text"
  88. @click="rowCell(row, index)"
  89. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  90. >
  91. <el-button
  92. size="small"
  93. icon="el-icon-delete"
  94. type="text"
  95. @click="rowDel(row, index)"
  96. >删除</el-button
  97. >
  98. </template>
  99. <template slot="cname" slot-scope="{ row, index }">
  100. <span v-if="row.$cellEdit" style="display:flex">
  101. <el-select
  102. v-model="row.itemId"
  103. placeholder="请选择"
  104. size="small"
  105. style="width:60%"
  106. @change="cnameChange(row, index)"
  107. >
  108. <el-option
  109. v-for="item in goodsoptions"
  110. :key="item.id"
  111. :label="item.cname"
  112. :value="item.id"
  113. >
  114. </el-option>
  115. </el-select>
  116. <el-button
  117. icon="el-icon-search"
  118. size="small"
  119. @click="rePick(row, index)"
  120. ></el-button>
  121. </span>
  122. <span v-else> {{ row.cname }}</span>
  123. </template>
  124. <template slot="actualQuantity" slot-scope="{ row, index }">
  125. <el-input
  126. v-if="row.$cellEdit"
  127. v-model="row.actualQuantity"
  128. size="small"
  129. ></el-input>
  130. <span v-else>{{ row.actualQuantity }}</span>
  131. </template>
  132. <template slot="price" slot-scope="{ row, index }">
  133. <el-input
  134. v-if="row.$cellEdit"
  135. v-model="row.price"
  136. size="small"
  137. ></el-input>
  138. <span v-else>{{ row.price }}</span>
  139. </template>
  140. </avue-crud>
  141. </basic-container>
  142. </div>
  143. <el-dialog
  144. title="导入商品"
  145. append-to-body
  146. class="el-dialogDeep"
  147. :visible.sync="dialogVisible"
  148. width="80%"
  149. :close-on-click-modal="false"
  150. :destroy-on-close="true"
  151. :close-on-press-escape="false"
  152. @close="closeGoods"
  153. top="5vh"
  154. v-dialog-drag
  155. >
  156. <span>
  157. <el-row>
  158. <el-col :span="4">
  159. <div>
  160. <el-scrollbar>
  161. <basic-container>
  162. <avue-tree
  163. :option="treeOption"
  164. @node-click="nodeClick"
  165. :style="treeStyle"
  166. />
  167. </basic-container>
  168. </el-scrollbar>
  169. </div>
  170. </el-col>
  171. <el-col :span="20">
  172. <avue-crud
  173. :option="goodsOption"
  174. :table-loading="loading"
  175. :data="goodsList"
  176. ref="goodsCrud"
  177. :search.sync="search"
  178. @search-change="searchChange"
  179. @selection-change="selectionChange"
  180. @row-click="rowClick"
  181. :page.sync="page"
  182. @on-load="onLoad"
  183. @saveColumn="saveGoodsColumn"
  184. @resetColumn="resetGoodsColumn"
  185. :cell-style="cellStyle"
  186. ></avue-crud>
  187. </el-col>
  188. </el-row>
  189. </span>
  190. <span slot="footer" class="dialog-footer">
  191. <el-button @click="dialogVisible = false">取 消</el-button>
  192. <el-button
  193. type="primary"
  194. @click="importGoods"
  195. :disabled="selectionList.length == 0"
  196. >导入</el-button
  197. >
  198. </span>
  199. </el-dialog>
  200. </div>
  201. </template>
  202. <script>
  203. import tableOption from "./config/customerContact.json";
  204. import goodsOption from "./config/commodity.json";
  205. import {getDeptLazyTree,
  206. getGoods,} from "@/api/basicData/customerInquiry";
  207. import {getUserInfo} from "@/api/system/user";
  208. import {selectGoodsNum} from "@/api/basicData/inventoryAccount"; // 库存查询
  209. export default {
  210. name: "detail",
  211. props: {
  212. detailData: {
  213. type: Object
  214. }
  215. },
  216. data() {
  217. return {
  218. pageLoading: false,
  219. form: {},
  220. option: {
  221. menuBtn: false,
  222. labelWidth: 100,
  223. column: [
  224. {
  225. label: "客户名称",
  226. prop: "corpId",
  227. rules: [
  228. {
  229. required: true,
  230. message: " ",
  231. trigger: "change"
  232. }
  233. ],
  234. span: 16,
  235. slot: true
  236. },
  237. {
  238. label: "系统号",
  239. prop: "sysNo",
  240. span: 8,
  241. disabled: true
  242. },
  243. {
  244. label: "业务时间",
  245. prop: "businesDate",
  246. span: 8,
  247. type: "date",
  248. format: "yyyy-MM-dd",
  249. valueFormat: "yyyy-MM-dd 00:00:00",
  250. rules: [
  251. {
  252. required: true,
  253. message: "",
  254. trigger: "blur"
  255. }
  256. ]
  257. },
  258. {
  259. label: "电话",
  260. prop: "corpTel",
  261. span: 8
  262. },
  263. {
  264. label: "地址",
  265. prop: "arrivalAddress",
  266. span: 8
  267. },
  268. {
  269. label: "打印时间",
  270. prop: "a",
  271. span: 8,
  272. disabled: true
  273. },
  274. {
  275. label: "客户欠款",
  276. prop: "a",
  277. span: 8,
  278. },
  279. {
  280. label: "总数量",
  281. prop: "b",
  282. span: 8,
  283. },
  284. {
  285. label: "应收金额",
  286. prop: "c",
  287. span: 8,
  288. },
  289. {
  290. label: "总金额",
  291. prop: "d",
  292. span: 8,
  293. },
  294. {
  295. label: "经办人",
  296. prop: "e",
  297. span: 8,
  298. },
  299. {
  300. label: "制单人",
  301. prop: "createUser",
  302. span: 8,
  303. disabled: true,
  304. },
  305. {
  306. label: "结算方式",
  307. prop: "paymentType",
  308. span: 8,
  309. type: "select",
  310. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  311. props: {
  312. label: "dictValue",
  313. value: "dictValue"
  314. }
  315. },
  316. {
  317. label: "配送方式",
  318. prop: "f",
  319. span: 8,
  320. },
  321. {
  322. label: "发货仓库",
  323. prop: "storageId",
  324. span: 8,
  325. },
  326. ],
  327. },
  328. dataList: [],
  329. tableOption: {},
  330. dialogVisible: false,
  331. selectionList: [],
  332. treeDeptId: null,
  333. reData: null,
  334. treeOption: {
  335. nodeKey: "id",
  336. lazy: true,
  337. treeLoad: function(node, resolve) {
  338. const parentId = node.level === 0 ? 0 : node.data.id;
  339. getDeptLazyTree(parentId).then(res => {
  340. resolve(
  341. res.data.data.map(item => {
  342. return {
  343. ...item,
  344. leaf: !item.hasChildren
  345. };
  346. })
  347. );
  348. });
  349. },
  350. addBtn: false,
  351. menu: false,
  352. size: "small",
  353. props: {
  354. label: "title",
  355. value: "value",
  356. children: "children"
  357. }
  358. },
  359. page: {
  360. pageSize: 10,
  361. currentPage: 1,
  362. total: 0
  363. },
  364. search: {},
  365. goodsList: [],
  366. loading: false,
  367. goodsOption: {},
  368. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  369. goodsoptions: [],
  370. // 仓库配置
  371. configurationWarehouse: {
  372. multipleChoices: false,
  373. multiple: false,
  374. collapseTags: false,
  375. placeholder: "请点击右边按钮选择",
  376. dicData: [],
  377. },
  378. }
  379. },
  380. async created() {
  381. this.tableOption = await this.getColumnData(
  382. this.getColumnName(79),
  383. tableOption
  384. );
  385. this.goodsOption = await this.getColumnData(
  386. this.getColumnName(80),
  387. goodsOption
  388. );
  389. getGoods(1, 500).then(res => {
  390. this.goodsoptions = res.data.data.records;
  391. });
  392. getUserInfo().then(res => {
  393. this.$set(this.form, 'createUser', res.data.data.realName)
  394. })
  395. if (this.detailData.id) {
  396. this.$set(this.form, 'paymentType', '到付')
  397. this.$set(this.form, 'id', this.detailData.id)
  398. this.$set(this.form, 'businesDate', this.detailData.row.businesDate)
  399. this.$set(this.form, 'corpId', this.detailData.row.corpsName)
  400. this.$set(this.form, 'corpTel', '1918766221')
  401. this.$set(this.form, 'arrivalAddress', '山东省青岛市')
  402. }
  403. },
  404. methods: {
  405. cellStyle() {
  406. return "padding:0;height:40px;";
  407. },
  408. openEdit() {},
  409. copyDoc() {
  410. this.$emit("copyOrder", this.form.id);
  411. },
  412. getCorpData(row) {},
  413. //修改提交触发
  414. editCustomer(status) {
  415. this.$message.success('保存成功')
  416. },
  417. //返回列表
  418. backToList() {
  419. this.$emit("goBack");
  420. },
  421. async saveColumn() {
  422. const inSave = await this.saveColumnData(
  423. this.getColumnName(79),
  424. this.tableOption
  425. );
  426. if (inSave) {
  427. this.$message.success("保存成功");
  428. //关闭窗口
  429. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  430. }
  431. },
  432. async resetColumn() {
  433. this.tableOption = tableOption;
  434. const inSave = await this.delColumnData(
  435. this.getColumnName(79),
  436. tableOption
  437. );
  438. if (inSave) {
  439. this.$message.success("重置成功");
  440. //关闭窗口
  441. setTimeout(() => {
  442. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  443. }, 1000);
  444. }
  445. },
  446. //商品明细导入
  447. newDetails() {
  448. // if (!this.form.corpId) {
  449. // return this.$message.error("请选择客户名称");
  450. // }
  451. this.dialogVisible = !this.dialogVisible;
  452. },
  453. importGoods() {
  454. if (this.reData) {
  455. if (this.selectionList.length != 1) {
  456. return this.$message.error("重新选择的时候只能选择一条数据");
  457. } else {
  458. this.selectionList.forEach(e => {
  459. this.dataList.forEach((item, index) => {
  460. if (index == this.reData.index) {
  461. item.itemId = e.id;
  462. item.code = e.code;
  463. item.cname = e.cname;
  464. item.corpId = e.corpId;
  465. item.corpName = e.corpName;
  466. item.brandItem = e.brandItem;
  467. item.specsOne = e.specsOne;
  468. item.specsTwo = e.specsTwo;
  469. item.typeno = e.typeno;
  470. item.priceCategory = e.goodsTypeName;
  471. item.$cellEdit = true;
  472. }
  473. });
  474. });
  475. }
  476. } else {
  477. this.selectionList.forEach(e => {
  478. this.dataList.push({
  479. itemId: e.id,
  480. code: e.code,
  481. cname: e.cname,
  482. brandItem: e.brandItem,
  483. specsOne: e.specsOne,
  484. specsTwo: e.specsTwo,
  485. typeno: e.typeno,
  486. corpId: e.corpId,
  487. corpName: e.corpName,
  488. price: 0,
  489. amount: 0,
  490. $cellEdit: true
  491. });
  492. });
  493. }
  494. this.dialogVisible = false;
  495. },
  496. closeGoods() {
  497. this.selectionList = [];
  498. this.treeDeptId = "";
  499. this.reData = null;
  500. },
  501. nodeClick(data) {
  502. this.treeDeptId = data.id;
  503. this.page.currentPage = 1;
  504. this.onLoad(this.page);
  505. },
  506. //费用查询
  507. onLoad(page, params = {}) {
  508. let obj = this.deepClone(Object.assign(params, this.search));
  509. this.loading = true;
  510. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  511. .then(res => {
  512. const data = res.data.data;
  513. this.page.total = data.total;
  514. this.goodsList = data.records;
  515. if (this.page.total) {
  516. this.goodsOption.height = window.innerHeight - 350;
  517. }
  518. })
  519. .finally(() => {
  520. this.loading = false;
  521. });
  522. },
  523. searchChange(params, done) {
  524. this.search = this.deepClone(params);
  525. this.onLoad(this.page, params);
  526. done();
  527. },
  528. selectionChange(list) {
  529. this.selectionList = list;
  530. },
  531. rowClick(row) {
  532. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  533. },
  534. async saveGoodsColumn() {
  535. const inSave = await this.saveColumnData(
  536. this.getColumnName(80),
  537. this.goodsOption
  538. );
  539. if (inSave) {
  540. this.$message.success("保存成功");
  541. //关闭窗口
  542. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  543. }
  544. },
  545. async resetGoodsColumn() {
  546. this.goodsOption = goodsOption;
  547. const inSave = await this.delColumnData(
  548. this.getColumnName(80),
  549. goodsOption
  550. );
  551. if (inSave) {
  552. this.$message.success("重置成功");
  553. //关闭窗口
  554. setTimeout(() => {
  555. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  556. }, 1000);
  557. }
  558. },
  559. openReport() {},
  560. rowCell(row, index) {
  561. if (row.$cellEdit == true) {
  562. this.$set(row, "$cellEdit", false);
  563. } else {
  564. this.$set(row, "$cellEdit", true);
  565. }
  566. },
  567. rowDel(row, index) {
  568. this.$confirm("确定删除数据?", {
  569. confirmButtonText: "确定",
  570. cancelButtonText: "取消",
  571. type: "warning"
  572. }).then(() => {
  573. if (row.id) {
  574. } else {
  575. this.$message({
  576. type: "success",
  577. message: "删除成功!"
  578. });
  579. this.data.splice(row.$index, 1);
  580. }
  581. });
  582. },
  583. cnameChange(row) {
  584. this.goodsoptions.forEach(e => {
  585. if (e.id == row.itemId) {
  586. row.cname = e.cname;
  587. row.code = e.code;
  588. row.corpId = e.corpId;
  589. row.corpName = e.corpName;
  590. row.brandItem = e.brandItem;
  591. row.specsOne = e.specsOne;
  592. row.specsTwo = e.specsTwo;
  593. row.typeno = e.typeno;
  594. row.priceCategory = e.goodsTypeName;
  595. row.purchaseAmount = 0;
  596. row.amount = 0;
  597. }
  598. });
  599. },
  600. rePick(row, index) {
  601. this.reData = {
  602. ...row,
  603. index: index
  604. };
  605. this.newDetails();
  606. },
  607. },
  608. }
  609. </script>
  610. <style lang="scss" scoped>
  611. .trading-form ::v-deep .el-form-item {
  612. margin-bottom: 8px !important;
  613. }
  614. ::v-deep .el-form-item__error {
  615. display: none !important;
  616. }
  617. ::v-deep .select-component {
  618. display: flex !important;
  619. }
  620. </style>