index.vue 13 KB

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