index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. :cell-style="cellStyle"
  20. :summary-method="summaryMethod"
  21. @selection-change="selectionChange"
  22. @expand-change="expandChange"
  23. @search-criteria-switch="searchCriteriaSwitch"
  24. >
  25. <template slot-scope="{ row }" slot="expand">
  26. <avue-crud
  27. :data="row.itemData"
  28. :option="itemOption"
  29. :table-loading="row.itemLoading"
  30. :cell-style="cellStyle"
  31. class="itemTable"
  32. ></avue-crud>
  33. </template>
  34. <template slot-scope="{ row }" slot="createUser">
  35. <span>{{ row.createUserName }}</span>
  36. </template>
  37. <template slot-scope="{ row }" slot="orderQuantity">
  38. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  39. </template>
  40. <template slot="portOfLoadSearch">
  41. <port-info v-model="search.portOfLoad" />
  42. </template>
  43. <template slot="portOfDestinationSearch">
  44. <port-info v-model="search.portOfDestination" />
  45. </template>
  46. <template slot="businesDateSearch">
  47. <el-date-picker
  48. v-model="search.businesDate"
  49. type="daterange"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期"
  52. format="yyyy-MM-dd"
  53. value-format="yyyy-MM-dd HH:mm:ss"
  54. :default-time="['00:00:00', '23:59:59']"
  55. >
  56. </el-date-picker>
  57. </template>
  58. <template slot="dateValiditySearch">
  59. <el-date-picker
  60. v-model="search.dateValidity"
  61. type="daterange"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. format="yyyy-MM-dd"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. :default-time="['00:00:00', '23:59:59']"
  67. >
  68. </el-date-picker>
  69. </template>
  70. <template slot="createTimeSearch">
  71. <el-date-picker
  72. v-model="search.createTime"
  73. type="daterange"
  74. start-placeholder="开始日期"
  75. end-placeholder="结束日期"
  76. format="yyyy-MM-dd"
  77. value-format="yyyy-MM-dd HH:mm:ss"
  78. :default-time="['00:00:00', '23:59:59']"
  79. >
  80. </el-date-picker>
  81. </template>
  82. <template slot="menuLeft">
  83. <el-button
  84. type="primary"
  85. icon="el-icon-plus"
  86. size="small"
  87. @click.stop="newAdd()"
  88. >创建单据
  89. </el-button>
  90. <el-button
  91. type="success"
  92. size="small"
  93. @click.stop="copyDoc()"
  94. :disabled="selectionList.length != 1"
  95. >复制单据</el-button
  96. >
  97. <el-button type="info" size="small">报表</el-button>
  98. </template>
  99. <template slot="corpIdSearch">
  100. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  101. </template>
  102. <template slot-scope="scope" slot="corpId">
  103. <span
  104. style="color: #409EFF;cursor: pointer"
  105. @click.stop="editOpen(scope.row, 1)"
  106. >{{ scope.row.corpsName }}
  107. </span>
  108. </template>
  109. <template slot-scope="scope" slot="orderNo">
  110. <span
  111. style="color: #409EFF;cursor: pointer"
  112. @click.stop="editOpen(scope.row, 1)"
  113. >{{ scope.row.orderNo }}
  114. </span>
  115. </template>
  116. <template slot-scope="scope" slot="grossProfitRate">
  117. {{ scope.row.grossProfitRate ? scope.row.grossProfitRate : 0 }}%
  118. </template>
  119. <template slot-scope="scope" slot="menu">
  120. <el-button
  121. type="text"
  122. icon="el-icon-delete"
  123. size="small"
  124. @click.stop="rowDel(scope.row, scope.index)"
  125. >删除
  126. </el-button>
  127. </template>
  128. </avue-crud>
  129. </basic-container>
  130. <detail-page
  131. @goBack="goBack"
  132. @copyOrder="copyOrder"
  133. :detailData="detailData"
  134. v-if="!show"
  135. ></detail-page>
  136. </div>
  137. </template>
  138. <script>
  139. import option from "./config/mainList.json";
  140. import {
  141. getList,
  142. remove,
  143. gainUser,
  144. getGoodsInfo
  145. } from "@/api/basicData/customerInquiry";
  146. import detailPage from "./detailsPage";
  147. import { defaultDate } from "@/util/date";
  148. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  149. import _ from "lodash";
  150. export default {
  151. name: "customerInformation",
  152. data() {
  153. return {
  154. search: {
  155. businesDate: defaultDate()
  156. },
  157. form: {},
  158. option: {},
  159. parentId: 0,
  160. dataList: [],
  161. page: {
  162. pageSize: 10,
  163. currentPage: 1,
  164. total: 0,
  165. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  166. },
  167. show: true,
  168. detailData: {},
  169. loading: false,
  170. searchShow: true,
  171. selectionList: [],
  172. itemOption: {
  173. align: "center",
  174. header: false,
  175. menu: false,
  176. column: [
  177. {
  178. label: "产品类别",
  179. prop: "priceCategory",
  180. width: 138,
  181. overHidden: true
  182. },
  183. {
  184. label: "产品名称",
  185. prop: "cname",
  186. width: 100,
  187. overHidden: true
  188. },
  189. {
  190. label: "产品描述",
  191. prop: "itemDescription",
  192. width: 100,
  193. overHidden: true
  194. },
  195. {
  196. label: "配件描述",
  197. prop: "partsDescribe",
  198. width: 100,
  199. overHidden: true
  200. },
  201. {
  202. label: "配件价格描述",
  203. prop: "partsPriceDescribe",
  204. width: 100,
  205. overHidden: true
  206. },
  207. {
  208. label: "数量",
  209. prop: "orderQuantity",
  210. width: 100,
  211. overHidden: true
  212. },
  213. {
  214. label: "金额",
  215. prop: "amount",
  216. width: 100,
  217. overHidden: true
  218. }
  219. ]
  220. }
  221. };
  222. },
  223. components: { detailPage },
  224. async created() {
  225. /**
  226. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  227. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  228. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  229. */
  230. this.option = await this.getColumnData(this.getColumnName(0), option);
  231. this.getWorkDicts("order_status").then(res => {
  232. this.findObject(this.option.column, "orderStatus").dicData =
  233. res.data.data;
  234. });
  235. gainUser().then(res => {
  236. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  237. });
  238. this.option.height = window.innerHeight - 210;
  239. },
  240. filters: {
  241. IntegerFormat(num) {
  242. return IntegerFormat(num);
  243. }
  244. },
  245. activated() {
  246. if (!this.$store.getters.bjStatus && !this.show) {
  247. this.show = true;
  248. }
  249. if (this.$route.query.id) {
  250. setTimeout(() => {
  251. this.editOpen({ id: this.$route.query.id }, 1);
  252. }, 100);
  253. }
  254. },
  255. methods: {
  256. searchCriteriaSwitch(type) {
  257. if (type) {
  258. this.option.height = this.option.height - 191;
  259. } else {
  260. this.option.height = this.option.height + 191;
  261. }
  262. this.$refs.crud.getTableHeight();
  263. },
  264. cellStyle() {
  265. return "padding:0;height:40px;";
  266. },
  267. expandChange(row) {
  268. if (!row.itemData) {
  269. getGoodsInfo({ id: row.id, tradeType: "CK" })
  270. .then(res => {
  271. this.dataList[row.$index].itemData = res.data.data;
  272. })
  273. .finally(() => {
  274. this.dataList[row.$index].itemLoading = false;
  275. });
  276. }
  277. },
  278. //删除列表后面的删除按钮触发触发(row, index, done)
  279. rowDel(row, index, done) {
  280. this.$confirm("确定删除数据?", {
  281. confirmButtonText: "确定",
  282. cancelButtonText: "取消",
  283. type: "warning"
  284. }).then(() => {
  285. remove(row.id).then(res => {
  286. if (res.data.code == 200) {
  287. this.$message({
  288. type: "success",
  289. message: "删除成功!"
  290. });
  291. this.onLoad(this.page, this.search);
  292. }
  293. });
  294. });
  295. },
  296. selectionChange(list) {
  297. this.selectionList = list;
  298. },
  299. editOpen(row, status) {
  300. this.detailData = {
  301. id: row.id,
  302. status: status
  303. };
  304. this.show = false;
  305. this.$store.commit("IN_BJ_STATUS");
  306. },
  307. copyDoc() {
  308. this.selectionList.forEach(e => {
  309. this.detailData = {
  310. id: e.id,
  311. status: "copy"
  312. };
  313. this.show = false;
  314. this.$store.commit("IN_BJ_STATUS");
  315. });
  316. },
  317. copyOrder(id) {
  318. this.show = true;
  319. this.detailData = {
  320. id: id,
  321. status: "copy"
  322. };
  323. this.$nextTick(() => {
  324. this.show = false;
  325. this.$store.commit("IN_BJ_STATUS");
  326. });
  327. },
  328. //点击搜索按钮触发
  329. searchChange(params, done) {
  330. if (params.businesDate) {
  331. params.orderStartDate = params.businesDate[0];
  332. params.orderEndDate = params.businesDate[1];
  333. }
  334. if (params.dateValidity) {
  335. params.dateValidityStart = params.dateValidity[0];
  336. params.dateValidityEnd = params.dateValidity[1];
  337. }
  338. if (params.createTime) {
  339. params.createTimeStart = params.createTime[0];
  340. params.createTimeEnd = params.createTime[1];
  341. }
  342. this.search = this.deepClone(params);
  343. delete params.businesDate;
  344. delete params.dateValidity;
  345. delete params.createTime;
  346. this.page.currentPage = 1;
  347. this.onLoad(this.page, params);
  348. done();
  349. },
  350. currentChange(val) {
  351. this.page.currentPage = val;
  352. },
  353. sizeChange(val) {
  354. this.page.currentPage = 1;
  355. this.page.pageSize = val;
  356. },
  357. onLoad(page, params) {
  358. if (this.search.businesDate && this.search.businesDate.length > 0) {
  359. params = {
  360. ...params,
  361. orderStartDate: this.search.businesDate[0],
  362. orderEndDate: this.search.businesDate[1]
  363. };
  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] = qtySum ? qtySum.toFixed(2) : "0.00";
  408. }
  409. //入库金额总计
  410. if (item.property == "amount") {
  411. sums[index] = micrometerFormat(instoreSum);
  412. }
  413. //金额总计
  414. if (item.property == "purchaseAmount") {
  415. sums[index] = micrometerFormat(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. width: 738px;
  488. }
  489. </style>