index.vue 13 KB

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