index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  5. <el-tab-pane label="处理中" name="second" />
  6. <!-- <el-tab-pane label="待确认" name="fifth" /> -->
  7. <el-tab-pane label="已完成" name="first" />
  8. <el-tab-pane label="已取消" name="third" />
  9. <el-tab-pane label="全部" name="fourth" />
  10. </el-tabs>
  11. <avue-crud ref="crud" :option="option" :data="dataList" v-model="form" :page.sync="page" :search.sync="search"
  12. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  13. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  14. @resetColumn="resetColumn" :cell-style="cellStyle" :summary-method="summaryMethod"
  15. @selection-change="selectionChange" @expand-change="expandChange" @search-criteria-switch="searchCriteriaSwitch">
  16. <template slot-scope="{ row }" slot="expand">
  17. <avue-crud :data="row.itemData" :option="itemOption" :table-loading="row.itemLoading" :cell-style="cellStyle"
  18. class="itemTable">
  19. <template slot-scope="{ row }" slot="orderQuantity">
  20. <span>{{ row.orderQuantity | decimalFormat2 }}</span>
  21. </template>
  22. <template slot-scope="{ row }" slot="price">
  23. <span>{{ row.price | decimalFormat2 }}</span>
  24. </template>
  25. <template slot-scope="{ row }" slot="amount">
  26. <span>{{ row.amount | decimalFormat2 }}</span>
  27. </template>
  28. </avue-crud>
  29. </template>
  30. <template slot-scope="{ row }" slot="createUser">
  31. <span>{{ row.createUserName }}</span>
  32. </template>
  33. <template slot-scope="{ row }" slot="orderQuantity">
  34. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  35. </template>
  36. <template slot-scope="{ row }" slot="amount">
  37. <span>{{ row.amount | decimalFormat2 }}</span>
  38. </template>
  39. <template slot-scope="{ row }" slot="orderStatus">
  40. <span v-for="item in orderStatusList" :style="{ color: item.colour }"
  41. v-if="item.dictValue == row.orderStatus">{{ row.orderStatus }}</span>
  42. </template>
  43. <template slot-scope="{ row }" slot="purchaseAmount">
  44. <span>{{ row.purchaseAmount | decimalFormat2 }}</span>
  45. </template>
  46. <template slot-scope="{ row }" slot="grossProfit">
  47. <span>{{ row.grossProfit | decimalFormat2 }}</span>
  48. </template>
  49. <template slot="portOfLoadSearch">
  50. <port-info v-model="search.portOfLoad" />
  51. </template>
  52. <template slot="portOfDestinationSearch">
  53. <port-info v-model="search.portOfDestination" />
  54. </template>
  55. <template slot="businesDateSearch">
  56. <el-date-picker v-model="search.businesDate" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  57. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  58. </el-date-picker>
  59. </template>
  60. <template slot="dateValiditySearch">
  61. <el-date-picker v-model="search.dateValidity" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  62. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  63. </el-date-picker>
  64. </template>
  65. <template slot="createTimeSearch">
  66. <el-date-picker v-model="search.createTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  67. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']">
  68. </el-date-picker>
  69. </template>
  70. <template slot="menuLeft">
  71. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newAdd()">创建单据
  72. </el-button>
  73. <el-button type="success" size="small" @click.stop="copyDoc()"
  74. :disabled="selectionList.length != 1">复制单据</el-button>
  75. <el-button type="info" size="small">报表打印</el-button>
  76. </template>
  77. <template slot="corpIdSearch">
  78. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  79. </template>
  80. <template slot-scope="scope" slot="corpId">
  81. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(scope.row, 1)">{{ scope.row.corpsName }}
  82. </span>
  83. </template>
  84. <template slot-scope="scope" slot="orderNo">
  85. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(scope.row, 1)">{{ scope.row.orderNo }}
  86. </span>
  87. </template>
  88. <template slot-scope="scope" slot="menu">
  89. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="rowDel(scope.row, scope.index)">删除
  90. </el-button>
  91. </template>
  92. </avue-crud>
  93. </basic-container>
  94. <detail-page @goBack="goBack" @copyOrder="copyOrder" :detailData="detailData" v-if="!show"></detail-page>
  95. </div>
  96. </template>
  97. <script>
  98. import option from "./config/mainList.json";
  99. import {
  100. getList,
  101. remove,
  102. gainUser,
  103. getGoodsInfo
  104. } from "@/api/basicData/customerInquiry";
  105. import detailPage from "./detailsPage";
  106. import { defaultDate } from "@/util/date";
  107. import { micrometerFormat2, IntegerFormat, decimalFormat2 } from "@/util/validate";
  108. import _ from "lodash";
  109. export default {
  110. name: "customerInformation",
  111. data() {
  112. return {
  113. activeName: 'second',
  114. tabType: 2,
  115. search: {
  116. businesDate: defaultDate()
  117. },
  118. form: {},
  119. option: {},
  120. parentId: 0,
  121. dataList: [],
  122. page: {
  123. pageSize: 20,
  124. currentPage: 1,
  125. total: 0,
  126. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  127. },
  128. orderStatusList: [],
  129. show: true,
  130. detailData: {},
  131. loading: false,
  132. searchShow: true,
  133. selectionList: [],
  134. itemOption: {
  135. align: "center",
  136. header: false,
  137. border: true,
  138. menu: false,
  139. column: [
  140. {
  141. label: "产品类别",
  142. prop: "priceCategory",
  143. width: 140,
  144. overHidden: true
  145. },
  146. {
  147. label: "产品名称",
  148. prop: "cname",
  149. width: 240,
  150. overHidden: true
  151. },
  152. {
  153. label: "产品描述",
  154. prop: "itemDescription",
  155. width: 240,
  156. overHidden: true
  157. },
  158. {
  159. label: "配件描述",
  160. prop: "partsDescribe",
  161. width: 240,
  162. overHidden: true
  163. },
  164. {
  165. label: "配件价格描述",
  166. prop: "partsPriceDescribe",
  167. width: 240,
  168. overHidden: true
  169. },
  170. {
  171. label: "数量",
  172. prop: "orderQuantity",
  173. width: 100,
  174. overHidden: true
  175. },
  176. {
  177. label: "单价",
  178. prop: "price",
  179. width: 100,
  180. overHidden: true
  181. },
  182. {
  183. label: "金额",
  184. prop: "amount",
  185. width: 100,
  186. overHidden: true
  187. }
  188. ]
  189. }
  190. };
  191. },
  192. components: { detailPage },
  193. async created() {
  194. /**
  195. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  196. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  197. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  198. */
  199. this.option = await this.getColumnData(this.getColumnName(0), option);
  200. this.getWorkDicts("order_status").then(res => {
  201. this.findObject(this.option.column, "orderStatus").dicData =
  202. res.data.data;
  203. this.orderStatusList = res.data.data
  204. });
  205. gainUser().then(res => {
  206. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  207. });
  208. this.option.height = window.innerHeight - 260;
  209. },
  210. filters: {
  211. IntegerFormat(num) {
  212. return IntegerFormat(num);
  213. },
  214. decimalFormat2(num) {
  215. return decimalFormat2(num);
  216. }
  217. },
  218. activated() {
  219. if (!this.$store.getters.bjStatus && !this.show) {
  220. this.show = true;
  221. }
  222. if (this.$route.query.id) {
  223. setTimeout(() => {
  224. this.editOpen({ id: this.$route.query.id }, 1);
  225. }, 100);
  226. }
  227. },
  228. methods: {
  229. handleClick(tab, event) {
  230. if (this.activeName == 'first') {
  231. this.tabType = 1
  232. } else if (this.activeName == 'second') {
  233. this.tabType = 2
  234. } else if (this.activeName == 'third') {
  235. this.tabType = 3
  236. } else if (this.activeName == 'fourth') {
  237. this.tabType = ''
  238. } else if (this.activeName == 'fifth') {
  239. this.tabType = 4
  240. }
  241. this.onLoad(this.page, this.search);
  242. },
  243. searchCriteriaSwitch(type) {
  244. if (type) {
  245. this.option.height = this.option.height - 191;
  246. } else {
  247. this.option.height = this.option.height + 191;
  248. }
  249. this.$refs.crud.getTableHeight();
  250. },
  251. cellStyle() {
  252. return "padding:0;height:40px;";
  253. },
  254. expandChange(row) {
  255. if (!row.itemData) {
  256. getGoodsInfo({ id: row.id, tradeType: "CK" })
  257. .then(res => {
  258. this.dataList[row.$index].itemData = res.data.data;
  259. })
  260. .finally(() => {
  261. this.dataList[row.$index].itemLoading = false;
  262. });
  263. }
  264. },
  265. //删除列表后面的删除按钮触发触发(row, index, done)
  266. rowDel(row, index, done) {
  267. this.$confirm("确定删除数据?", {
  268. confirmButtonText: "确定",
  269. cancelButtonText: "取消",
  270. type: "warning"
  271. }).then(() => {
  272. remove(row.id).then(res => {
  273. if (res.data.code == 200) {
  274. this.$message({
  275. type: "success",
  276. message: "删除成功!"
  277. });
  278. this.onLoad(this.page, this.search);
  279. }
  280. });
  281. });
  282. },
  283. selectionChange(list) {
  284. this.selectionList = list;
  285. },
  286. editOpen(row, status) {
  287. this.detailData = {
  288. id: row.id,
  289. status: status
  290. };
  291. this.show = false;
  292. this.$store.commit("IN_BJ_STATUS");
  293. },
  294. copyDoc() {
  295. this.selectionList.forEach(e => {
  296. this.detailData = {
  297. id: e.id,
  298. status: "copy"
  299. };
  300. this.show = false;
  301. this.$store.commit("IN_BJ_STATUS");
  302. });
  303. },
  304. copyOrder(id) {
  305. this.show = true;
  306. this.detailData = {
  307. id: id,
  308. status: "copy"
  309. };
  310. this.$nextTick(() => {
  311. this.show = false;
  312. this.$store.commit("IN_BJ_STATUS");
  313. });
  314. },
  315. //点击搜索按钮触发
  316. searchChange(params, done) {
  317. if (params.businesDate) {
  318. params.orderStartDate = params.businesDate[0];
  319. params.orderEndDate = params.businesDate[1];
  320. } else {
  321. delete params.orderStartDate
  322. delete params.orderEndDate
  323. }
  324. if (params.dateValidity) {
  325. params.dateValidityStart = params.dateValidity[0];
  326. params.dateValidityEnd = params.dateValidity[1];
  327. } else {
  328. delete params.dateValidityStart
  329. delete params.dateValidityEnd
  330. }
  331. if (params.createTime) {
  332. params.createTimeStart = params.createTime[0];
  333. params.createTimeEnd = params.createTime[1];
  334. } else {
  335. delete params.createTimeStart
  336. delete params.createTimeEnd
  337. }
  338. this.search = this.deepClone(params);
  339. delete params.businesDate;
  340. delete params.dateValidity;
  341. delete params.createTime;
  342. this.page.currentPage = 1;
  343. this.onLoad(this.page, params);
  344. done();
  345. },
  346. currentChange(val) {
  347. this.page.currentPage = val;
  348. },
  349. sizeChange(val) {
  350. this.page.currentPage = 1;
  351. this.page.pageSize = val;
  352. },
  353. onLoad(page, params) {
  354. if (this.search.businesDate && this.search.businesDate.length > 0) {
  355. params = {
  356. ...params,
  357. orderStartDate: this.search.businesDate[0],
  358. orderEndDate: this.search.businesDate[1]
  359. };
  360. }
  361. params = {
  362. ...params,
  363. tabType: this.tabType
  364. }
  365. let data = this.deepClone(Object.assign(params, this.search));
  366. delete data.businesDate;
  367. delete data.dateValidity;
  368. delete data.createTime;
  369. this.loading = true;
  370. this.dataList.forEach(item => {
  371. this.$refs.crud.toggleRowExpansion(item, false);
  372. });
  373. getList(page.currentPage, page.pageSize, data)
  374. .then(res => {
  375. if (res.data.data.records) {
  376. res.data.data.records.forEach(e => {
  377. e.itemLoading = true;
  378. });
  379. }
  380. this.dataList = res.data.data.records ? res.data.data.records : [];
  381. this.page.total = res.data.data.total;
  382. })
  383. .finally(() => {
  384. this.loading = false;
  385. });
  386. },
  387. summaryMethod({ columns, data }) {
  388. const sums = [];
  389. if (columns.length > 0) {
  390. columns.forEach((item, index) => {
  391. sums[0] = "合计";
  392. if (
  393. item.property == "orderQuantity" ||
  394. item.property == "amount" ||
  395. item.property == "purchaseAmount"
  396. ) {
  397. let qtySum = 0;
  398. let instoreSum = 0;
  399. let totalSum = 0;
  400. data.forEach(e => {
  401. qtySum = _.add(qtySum, Number(e.orderQuantity));
  402. instoreSum = _.add(instoreSum, Number(e.amount));
  403. totalSum = _.add(totalSum, Number(e.purchaseAmount));
  404. });
  405. //数量总计
  406. if (item.property == "orderQuantity") {
  407. sums[index] = Number(qtySum ? qtySum.toFixed(2) : "0");
  408. }
  409. //入库金额总计
  410. if (item.property == "amount") {
  411. sums[index] = micrometerFormat2(instoreSum);
  412. }
  413. //金额总计
  414. if (item.property == "purchaseAmount") {
  415. sums[index] = micrometerFormat2(totalSum);
  416. }
  417. }
  418. });
  419. }
  420. return sums;
  421. },
  422. refreshChange() {
  423. this.onLoad(this.page, this.search);
  424. },
  425. newAdd() {
  426. this.show = false;
  427. this.$store.commit("IN_BJ_STATUS");
  428. },
  429. goBack() {
  430. if (this.$route.query.id) {
  431. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  432. this.$router.push({
  433. path: "/exportTrade/customerInquiry/index"
  434. });
  435. }
  436. this.detailData = this.$options.data().detailData;
  437. this.show = true;
  438. this.onLoad(this.page, this.search);
  439. this.$store.commit("OUT_BJ_STATUS");
  440. },
  441. async saveColumn() {
  442. /**
  443. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  444. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  445. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  446. */
  447. const inSave = await this.saveColumnData(
  448. this.getColumnName(0),
  449. this.option
  450. );
  451. if (inSave) {
  452. this.$nextTick(() => {
  453. this.$refs.crud.doLayout();
  454. });
  455. this.$message.success("保存成功");
  456. //关闭窗口
  457. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  458. }
  459. },
  460. async resetColumn() {
  461. this.option = option;
  462. const inSave = await this.delColumnData(this.getColumnName(0), option);
  463. if (inSave) {
  464. this.$nextTick(() => {
  465. this.$refs.crud.doLayout();
  466. });
  467. this.$message.success("重置成功");
  468. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  469. }
  470. }
  471. },
  472. watch: {
  473. option: function () {
  474. this.search.businesDate = defaultDate();
  475. }
  476. }
  477. };
  478. </script>
  479. <style scoped>
  480. ::v-deep .select-component {
  481. display: flex;
  482. }
  483. .page-crad ::v-deep .basic-container__card {
  484. height: 94.2vh;
  485. }
  486. .itemTable ::v-deep .el-table {
  487. margin-left: 50px;
  488. width: 100%;
  489. }
  490. </style>