detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. />
  50. </template>
  51. <template slot="belongToCorpId">
  52. <crop-select
  53. v-model="form.belongToCorpId"
  54. @getCorpData="getGSData"
  55. corpType="GS"
  56. />
  57. </template>
  58. <template slot="storageId">
  59. <warehouse-select
  60. v-model="form.storageId"
  61. :configuration="configurationWarehouse"/>
  62. </template>
  63. </avue-form>
  64. </basic-container>
  65. <containerTitle title="商品信息"/>
  66. <basic-container>
  67. <avue-crud
  68. ref="crud"
  69. :data="dataList"
  70. :option="tableOption"
  71. :cell-style="cellStyle"
  72. @saveColumn="saveColumn"
  73. @resetColumn="resetColumn"
  74. >
  75. <template slot="menuLeft">
  76. <el-button
  77. type="primary"
  78. icon="el-icon-plus"
  79. size="small"
  80. @click.stop="newDetails"
  81. >录入明细</el-button>
  82. <el-button
  83. type="info"
  84. icon="el-icon-printer"
  85. size="small"
  86. @click.stop="openReport()"
  87. >报 表</el-button
  88. >
  89. </template>
  90. <template slot="menu" slot-scope="{ row, index }">
  91. <el-button
  92. size="small"
  93. icon="el-icon-edit"
  94. type="text"
  95. @click="rowCell(row, index)"
  96. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  97. >
  98. <el-button
  99. size="small"
  100. icon="el-icon-delete"
  101. type="text"
  102. @click="rowDel(row, index)"
  103. >删除</el-button
  104. >
  105. </template>
  106. <template slot="cname" slot-scope="{ row, index }">
  107. <span v-if="row.$cellEdit" style="display:flex">
  108. <el-select
  109. v-model="row.itemId"
  110. placeholder="请选择"
  111. size="small"
  112. style="width:60%"
  113. @change="cnameChange(row, index)"
  114. >
  115. <el-option
  116. v-for="item in goodsoptions"
  117. :key="item.id"
  118. :label="item.cname"
  119. :value="item.id"
  120. >
  121. </el-option>
  122. </el-select>
  123. <el-button
  124. icon="el-icon-search"
  125. size="small"
  126. @click="rePick(row, index)"
  127. ></el-button>
  128. </span>
  129. <span v-else> {{ row.cname }}</span>
  130. </template>
  131. <template slot="actualQuantity" slot-scope="{ row, index }">
  132. <el-input-number
  133. v-if="row.$cellEdit"
  134. v-model="row.actualQuantity"
  135. size="small"
  136. :controls="false"
  137. :precision="0"
  138. @input="amountChange(row)"
  139. style="width: 100%"
  140. />
  141. <span v-else>{{ row.actualQuantity }}</span>
  142. </template>
  143. <template slot="price" slot-scope="{ row, index }">
  144. <el-input-number
  145. v-if="row.$cellEdit"
  146. v-model="row.price"
  147. size="small"
  148. :controls="false"
  149. :precision="2"
  150. @input="amountChange(row)"
  151. style="width: 100%"
  152. ></el-input-number>
  153. <span v-else>{{ row.price }}</span>
  154. </template>
  155. <!-- 单位-->
  156. <template slot="a" slot-scope="{ row, index }">
  157. <el-input
  158. v-if="row.$cellEdit"
  159. v-model="row.a"
  160. size="small"
  161. ></el-input>
  162. <span v-else>{{ row.a }}</span>
  163. </template>
  164. <!-- 尺寸-->
  165. <template slot="size" slot-scope="{ row, index }">
  166. <el-input
  167. v-if="row.$cellEdit"
  168. v-model="row.size"
  169. size="small"
  170. ></el-input>
  171. <span v-else>{{ row.size }}</span>
  172. </template>
  173. </avue-crud>
  174. </basic-container>
  175. <containerTitle title="详细信息"/>
  176. <basic-container :showBtn="true">
  177. <avue-form
  178. ref="form"
  179. class="trading-form"
  180. v-model="form"
  181. :option="detailOption"
  182. ></avue-form>
  183. </basic-container>
  184. <containerTitle title="附件管理"></containerTitle>
  185. <c-upload
  186. :data="uploadData"
  187. deleteUrl="/api/blade-client/corpsbank/update"
  188. :enumerationValue="84"
  189. />
  190. </div>
  191. <el-dialog
  192. title="导入商品"
  193. append-to-body
  194. class="el-dialogDeep"
  195. :visible.sync="dialogVisible"
  196. width="80%"
  197. :close-on-click-modal="false"
  198. :destroy-on-close="true"
  199. :close-on-press-escape="false"
  200. @close="closeGoods"
  201. top="5vh"
  202. v-dialog-drag
  203. >
  204. <span>
  205. <el-row>
  206. <el-col :span="4">
  207. <div>
  208. <el-scrollbar>
  209. <basic-container>
  210. <avue-tree
  211. :option="treeOption"
  212. @node-click="nodeClick"
  213. :style="treeStyle"
  214. />
  215. </basic-container>
  216. </el-scrollbar>
  217. </div>
  218. </el-col>
  219. <el-col :span="20">
  220. <avue-crud
  221. :option="goodsOption"
  222. :table-loading="loading"
  223. :data="goodsList"
  224. ref="goodsCrud"
  225. :search.sync="search"
  226. @search-change="searchChange"
  227. @selection-change="selectionChange"
  228. @row-click="rowClick"
  229. :page.sync="page"
  230. @on-load="onLoad"
  231. @saveColumn="saveGoodsColumn"
  232. @resetColumn="resetGoodsColumn"
  233. :cell-style="cellStyle"
  234. ></avue-crud>
  235. </el-col>
  236. </el-row>
  237. </span>
  238. <span slot="footer" class="dialog-footer">
  239. <el-button @click="dialogVisible = false">取 消</el-button>
  240. <el-button
  241. type="primary"
  242. @click="importGoods"
  243. :disabled="selectionList.length == 0"
  244. >导入</el-button
  245. >
  246. </span>
  247. </el-dialog>
  248. </div>
  249. </template>
  250. <script>
  251. import tableOption from "./config/customerContact.json";
  252. import goodsOption from "./config/commodity.json";
  253. import {getDeptLazyTree,
  254. getGoods,} from "@/api/basicData/customerInquiry";
  255. import {getUserInfo} from "@/api/system/user";
  256. import {selectGoodsNum} from "@/api/basicData/inventoryAccount"; // 库存查询
  257. import {detail as KHDetail} from "@/api/basicData/customerInformation";
  258. export default {
  259. name: "detail",
  260. props: {
  261. detailData: {
  262. type: Object
  263. }
  264. },
  265. data() {
  266. return {
  267. pageLoading: false,
  268. form: {},
  269. option: {
  270. menuBtn: false,
  271. labelWidth: 100,
  272. column: [
  273. {
  274. label: "客户名称",
  275. prop: "corpId",
  276. rules: [
  277. {
  278. required: true,
  279. message: " ",
  280. trigger: "change"
  281. }
  282. ],
  283. span: 16,
  284. slot: true
  285. },
  286. {
  287. label: "业务时间",
  288. prop: "businesDate",
  289. span: 8,
  290. type: "date",
  291. format: "yyyy-MM-dd",
  292. valueFormat: "yyyy-MM-dd 00:00:00",
  293. rules: [
  294. {
  295. required: true,
  296. message: "",
  297. trigger: "blur"
  298. }
  299. ]
  300. },
  301. {
  302. label: "所属公司",
  303. prop: "belongToCorpId",
  304. rules: [
  305. {
  306. required: true,
  307. message: " ",
  308. trigger: "change"
  309. }
  310. ],
  311. span: 16,
  312. slot: true
  313. },
  314. {
  315. label: "电话",
  316. prop: "corpTel",
  317. span: 8
  318. },
  319. {
  320. label: "地址",
  321. prop: "arrivalAddress",
  322. span: 8
  323. },
  324. {
  325. label: "经办人",
  326. prop: "e",
  327. span: 8,
  328. },
  329. {
  330. label: "结算方式",
  331. prop: "paymentType",
  332. span: 8,
  333. type: "select",
  334. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  335. props: {
  336. label: "dictValue",
  337. value: "dictValue"
  338. }
  339. },
  340. {
  341. label: "配送方式",
  342. prop: "f",
  343. span: 8,
  344. },
  345. {
  346. label: "发货仓库",
  347. prop: "storageId",
  348. span: 8,
  349. },
  350. {
  351. label: "备注",
  352. prop: "orderRemark",
  353. type: "textarea",
  354. minRows: 2,
  355. span: 24
  356. },
  357. ],
  358. },
  359. detailOption: {
  360. menuBtn: false,
  361. labelWidth: 100,
  362. column: [
  363. {
  364. label: "系统号",
  365. prop: "sysNo",
  366. span: 8,
  367. disabled: true
  368. },
  369. {
  370. label: "打印时间",
  371. prop: "a",
  372. span: 8,
  373. disabled: true
  374. },
  375. {
  376. label: "打印次数",
  377. prop: "a",
  378. span: 8,
  379. disabled: true
  380. },
  381. {
  382. label: "客户欠款",
  383. prop: "a",
  384. span: 8,
  385. disabled: true
  386. },
  387. {
  388. label: "总数量",
  389. prop: "b",
  390. span: 8,
  391. disabled: true
  392. },
  393. {
  394. label: "应收金额",
  395. prop: "c",
  396. span: 8,
  397. disabled: true
  398. },
  399. {
  400. label: "总金额",
  401. prop: "d",
  402. span: 8,
  403. disabled: true
  404. },
  405. {
  406. label: "制单人",
  407. prop: "createUser",
  408. span: 8,
  409. disabled: true,
  410. },
  411. ]
  412. },
  413. dataList: [],
  414. tableOption: {},
  415. dialogVisible: false,
  416. selectionList: [],
  417. treeDeptId: null,
  418. reData: null,
  419. treeOption: {
  420. nodeKey: "id",
  421. lazy: true,
  422. treeLoad: function(node, resolve) {
  423. const parentId = node.level === 0 ? 0 : node.data.id;
  424. getDeptLazyTree(parentId).then(res => {
  425. resolve(
  426. res.data.data.map(item => {
  427. return {
  428. ...item,
  429. leaf: !item.hasChildren
  430. };
  431. })
  432. );
  433. });
  434. },
  435. addBtn: false,
  436. menu: false,
  437. size: "small",
  438. props: {
  439. label: "title",
  440. value: "value",
  441. children: "children"
  442. }
  443. },
  444. page: {
  445. pageSize: 10,
  446. currentPage: 1,
  447. total: 0
  448. },
  449. search: {},
  450. goodsList: [],
  451. loading: false,
  452. goodsOption: {},
  453. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  454. goodsoptions: [],
  455. // 仓库配置
  456. configurationWarehouse: {
  457. multipleChoices: false,
  458. multiple: false,
  459. collapseTags: false,
  460. placeholder: "请点击右边按钮选择",
  461. dicData: [],
  462. },
  463. uploadData: [],
  464. }
  465. },
  466. async created() {
  467. this.tableOption = await this.getColumnData(
  468. this.getColumnName(79),
  469. tableOption
  470. );
  471. this.goodsOption = await this.getColumnData(
  472. this.getColumnName(80),
  473. goodsOption
  474. );
  475. getGoods(1, 500).then(res => {
  476. this.goodsoptions = res.data.data.records;
  477. });
  478. getUserInfo().then(res => {
  479. this.$set(this.form, 'createUser', res.data.data.realName)
  480. })
  481. if (this.detailData.id) {
  482. this.$set(this.form, 'id', this.detailData.id)
  483. this.$set(this.form, 'businesDate', this.detailData.row.businesDate)
  484. this.$set(this.form, 'corpId', this.detailData.row.corpsName)
  485. this.$set(this.form, 'corpTel', this.detailData.row.tel)
  486. this.$set(this.form, 'arrivalAddress', this.detailData.row.attn)
  487. this.$set(this.form, 'createUser', this.detailData.row.createUser)
  488. this.$set(this.form, 'storageId', this.detailData.row.storageId)
  489. this.$set(this.form, 'paymentType', this.detailData.row.paymentType)
  490. this.$set(this.form, 'belongToCorpId', this.detailData.row.belongToCorpId)
  491. this.$set(this.form, 'e', this.detailData.row.e)
  492. this.$set(this.form, 'f', this.detailData.row.f)
  493. } else {
  494. this.dataList = [
  495. {
  496. code: null,
  497. cname: null,
  498. typeno: null,
  499. brandItem: null,
  500. specsOne: null,
  501. specsTwo: null,
  502. a: null,
  503. storageQuantity: 0,
  504. actualQuantity: 0,
  505. size: null,
  506. price: 0,
  507. amount: 0,
  508. $cellEdit: true
  509. }
  510. ]
  511. }
  512. },
  513. methods: {
  514. cellStyle() {
  515. return "padding:0;height:40px;";
  516. },
  517. openEdit() {},
  518. copyDoc() {
  519. this.$emit("copyOrder", this.form.id);
  520. },
  521. getCorpData(row) {
  522. KHDetail(row.id).then(res => {
  523. if (res.data.data.belongtocompany) {
  524. this.$set(this.form, 'belongToCorpId', res.data.data.belongtocompany)
  525. } else {
  526. this.$set(this.form, 'belongToCorpId', null)
  527. }
  528. })
  529. },
  530. getGSData(row) {},
  531. //修改提交触发
  532. editCustomer(status) {
  533. this.$message.success('保存成功')
  534. },
  535. //返回列表
  536. backToList() {
  537. this.$emit("goBack");
  538. },
  539. async saveColumn() {
  540. const inSave = await this.saveColumnData(
  541. this.getColumnName(79),
  542. this.tableOption
  543. );
  544. if (inSave) {
  545. this.$message.success("保存成功");
  546. //关闭窗口
  547. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  548. this.$nextTick(() => {
  549. this.$refs.crud.doLayout()
  550. })
  551. }
  552. },
  553. async resetColumn() {
  554. this.tableOption = tableOption;
  555. const inSave = await this.delColumnData(
  556. this.getColumnName(79),
  557. tableOption
  558. );
  559. if (inSave) {
  560. this.$nextTick(() => {
  561. this.$refs.crud.doLayout()
  562. })
  563. this.$message.success("重置成功");
  564. //关闭窗口
  565. setTimeout(() => {
  566. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  567. }, 1000);
  568. }
  569. },
  570. //商品明细导入
  571. newDetails() {
  572. // if (!this.form.corpId) {
  573. // return this.$message.error("请选择客户名称");
  574. // }
  575. this.dialogVisible = !this.dialogVisible;
  576. },
  577. importGoods() {
  578. if (this.reData) {
  579. if (this.selectionList.length != 1) {
  580. return this.$message.error("重新选择的时候只能选择一条数据");
  581. } else {
  582. this.selectionList.forEach(e => {
  583. this.dataList.forEach((item, index) => {
  584. if (index == this.reData.index) {
  585. selectGoodsNum({
  586. goodsId: e.id,
  587. itemType: e.typeno,
  588. tradeType: 'GN'
  589. }).then((res) => {
  590. item.storageQuantity = res.data.data
  591. })
  592. item.itemId = e.id;
  593. item.code = e.code;
  594. item.cname = e.cname;
  595. item.corpId = e.corpId;
  596. item.corpName = e.corpName;
  597. item.brandItem = e.brandItem;
  598. item.specsOne = e.specsOne;
  599. item.specsTwo = e.specsTwo;
  600. item.typeno = e.typeno;
  601. item.priceCategory = e.goodsTypeName;
  602. item.$cellEdit = true;
  603. }
  604. });
  605. });
  606. }
  607. } else {
  608. this.selectionList.forEach(e => {
  609. selectGoodsNum({
  610. goodsId: e.id,
  611. itemType: e.typeno,
  612. tradeType: 'GN'
  613. }).then((res) => {
  614. e.storageQuantity = res.data.data
  615. this.dataList.push({
  616. itemId: e.id,
  617. code: e.code,
  618. cname: e.cname,
  619. brandItem: e.brandItem,
  620. specsOne: e.specsOne,
  621. specsTwo: e.specsTwo,
  622. typeno: e.typeno,
  623. corpId: e.corpId,
  624. corpName: e.corpName,
  625. price: 0,
  626. amount: 0,
  627. actualQuantity: 0,
  628. storageQuantity: e.storageQuantity,
  629. $cellEdit: true
  630. });
  631. })
  632. });
  633. }
  634. this.dialogVisible = false;
  635. },
  636. closeGoods() {
  637. this.selectionList = [];
  638. this.treeDeptId = "";
  639. this.reData = null;
  640. },
  641. nodeClick(data) {
  642. this.treeDeptId = data.id;
  643. this.page.currentPage = 1;
  644. this.onLoad(this.page);
  645. },
  646. //费用查询
  647. onLoad(page, params = {}) {
  648. let obj = this.deepClone(Object.assign(params, this.search));
  649. this.loading = true;
  650. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  651. .then(res => {
  652. const data = res.data.data;
  653. this.page.total = data.total;
  654. this.goodsList = data.records;
  655. if (this.page.total) {
  656. this.goodsOption.height = window.innerHeight - 350;
  657. }
  658. })
  659. .finally(() => {
  660. this.loading = false;
  661. });
  662. },
  663. searchChange(params, done) {
  664. this.search = this.deepClone(params);
  665. this.onLoad(this.page, params);
  666. done();
  667. },
  668. selectionChange(list) {
  669. this.selectionList = list;
  670. },
  671. rowClick(row) {
  672. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  673. },
  674. async saveGoodsColumn() {
  675. const inSave = await this.saveColumnData(
  676. this.getColumnName(80),
  677. this.goodsOption
  678. );
  679. if (inSave) {
  680. this.$message.success("保存成功");
  681. //关闭窗口
  682. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  683. this.$nextTick(() => {
  684. this.$refs.goodsCrud.doLayout()
  685. })
  686. }
  687. },
  688. async resetGoodsColumn() {
  689. this.goodsOption = goodsOption;
  690. const inSave = await this.delColumnData(
  691. this.getColumnName(80),
  692. goodsOption
  693. );
  694. if (inSave) {
  695. this.$nextTick(() => {
  696. this.$refs.goodsCrud.doLayout()
  697. })
  698. this.$message.success("重置成功");
  699. //关闭窗口
  700. setTimeout(() => {
  701. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  702. }, 1000);
  703. }
  704. },
  705. openReport() {},
  706. rowCell(row, index) {
  707. if (row.$cellEdit == true) {
  708. this.$set(row, "$cellEdit", false);
  709. } else {
  710. this.$set(row, "$cellEdit", true);
  711. }
  712. },
  713. rowDel(row, index) {
  714. this.$confirm("确定删除数据?", {
  715. confirmButtonText: "确定",
  716. cancelButtonText: "取消",
  717. type: "warning"
  718. }).then(() => {
  719. if (row.id) {
  720. } else {
  721. this.$message({
  722. type: "success",
  723. message: "删除成功!"
  724. });
  725. this.data.splice(row.$index, 1);
  726. }
  727. });
  728. },
  729. cnameChange(row) {
  730. this.goodsoptions.forEach(e => {
  731. if (e.id == row.itemId) {
  732. selectGoodsNum({
  733. goodsId: e.id,
  734. itemType: e.typeno,
  735. tradeType: 'GN'
  736. }).then(res => {
  737. row.storageQuantity = res.data.data
  738. row.cname = e.cname;
  739. row.code = e.code;
  740. row.corpId = e.corpId;
  741. row.corpName = e.corpName;
  742. row.brandItem = e.brandItem;
  743. row.specsOne = e.specsOne;
  744. row.specsTwo = e.specsTwo;
  745. row.typeno = e.typeno;
  746. row.priceCategory = e.goodsTypeName;
  747. row.purchaseAmount = 0;
  748. row.amount = 0;
  749. })
  750. }
  751. });
  752. },
  753. rePick(row, index) {
  754. this.reData = {
  755. ...row,
  756. index: index
  757. };
  758. this.newDetails();
  759. },
  760. // 商品信息价格计算
  761. amountChange(row) {
  762. if (!row.actualQuantity) {
  763. row.actualQuantity = 0;
  764. }
  765. if (!row.price) {
  766. row.price = 0;
  767. }
  768. row.amount = Number(row.price) * Number(row.actualQuantity)
  769. },
  770. },
  771. }
  772. </script>
  773. <style lang="scss" scoped>
  774. .trading-form ::v-deep .el-form-item {
  775. margin-bottom: 8px !important;
  776. }
  777. ::v-deep .el-form-item__error {
  778. display: none !important;
  779. }
  780. ::v-deep .select-component {
  781. display: flex !important;
  782. }
  783. </style>