index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div>
  3. <basic-container class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  5. :cell-style="cellStyle" @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  7. @resetColumn="resetColumn" @search-criteria-switch="searchCriteriaSwitch">
  8. <template slot="menuLeft">
  9. <el-button type="info" size="small" @click="outExport" icon="el-icon-download">导出</el-button>
  10. </template>
  11. </avue-crud>
  12. </basic-container>
  13. </div>
  14. </template>
  15. <script>
  16. import { getToken } from "@/util/auth";
  17. import { getList, exportExcel } from "@/api/statisticAnalysis/dataDetail";
  18. import { micrometerFormat } from "@/util/validate";
  19. import _ from "lodash";
  20. export default {
  21. name: "index",
  22. data() {
  23. return {
  24. form: {},
  25. search: {},
  26. dataList: [],
  27. loading: false,
  28. detailData: {},
  29. page: {
  30. pageSize: 20,
  31. currentPage: 1,
  32. total: 0,
  33. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  34. },
  35. option: {},
  36. defaultOption: {
  37. searchShow: true,
  38. align: "center",
  39. searchSpan: 8,
  40. border: true,
  41. index: true,
  42. addBtn: false,
  43. viewBtn: false,
  44. editBtn: false,
  45. delBtn: false,
  46. showSummary: true,
  47. summaryText: '合计',
  48. sumColumnList: [
  49. {
  50. name: "orderQuantity",
  51. type: "sum",
  52. decimals: 0
  53. },
  54. {
  55. name: "amount",
  56. type: "sum",
  57. },
  58. {
  59. name: "purchaseAmount",
  60. type: "sum",
  61. },
  62. ],
  63. searchIcon: true,
  64. searchIndex: 2,
  65. menu: false,
  66. column: [
  67. {
  68. label: "销售订单号",
  69. prop: "orderNo",
  70. search: true,
  71. overHidden: true,
  72. },
  73. {
  74. label: "客户名称",
  75. prop: "corpName",
  76. search: true,
  77. overHidden: true,
  78. },
  79. {
  80. label: "供应商",
  81. prop: "gysName",
  82. search: false,
  83. overHidden: true,
  84. },
  85. {
  86. label: "所属公司",
  87. prop: "belongCompany",
  88. search: true,
  89. overHidden: true,
  90. },
  91. {
  92. label: "制单日期",
  93. prop: "createTime",
  94. search: true,
  95. type: 'date',
  96. format: "yyyy-MM-dd",
  97. valueFormat: "yyyy-MM-dd",
  98. unlinkPanels: true,
  99. searchRange: true,
  100. overHidden: true,
  101. },
  102. {
  103. label: "产品名称",
  104. prop: "goodsName",
  105. search: false,
  106. overHidden: true,
  107. },
  108. {
  109. label: "产品编码",
  110. prop: "goodsCode",
  111. search: false,
  112. overHidden: true,
  113. },
  114. {
  115. label: "规格",
  116. prop: "typeNo",
  117. search: false,
  118. overHidden: true,
  119. },
  120. {
  121. label: "花纹",
  122. prop: "brandItem",
  123. search: false,
  124. overHidden: true,
  125. },
  126. {
  127. label: "数量",
  128. prop: "orderQuantity",
  129. search: false,
  130. overHidden: true,
  131. },
  132. {
  133. label: "金额",
  134. prop: "amount",
  135. search: false,
  136. overHidden: true,
  137. },
  138. {
  139. label: "采购价",
  140. prop: "purchaseAmount",
  141. search: false,
  142. overHidden: true,
  143. },
  144. {
  145. label: "包装要求",
  146. prop: "packageRemarks",
  147. search: true,
  148. overHidden: true,
  149. },
  150. ],
  151. },
  152. };
  153. },
  154. filters: {
  155. decimalFormat(num) {
  156. return num ? Number(num).toFixed(2) : "0.00";
  157. }
  158. },
  159. async created() {
  160. this.option = await this.getColumnData(this.getColumnName(127), this.defaultOption);
  161. let i = 0;
  162. this.option.column.forEach(item => {
  163. if (item.search) i++
  164. })
  165. if (i % 3 !== 0) {
  166. const num = 3 - Number(i % 3)
  167. this.option.searchMenuSpan = num * 8;
  168. this.option.searchMenuPosition = "right";
  169. }
  170. },
  171. methods: {
  172. cellStyle() {
  173. return "padding:0;height:40px;";
  174. },
  175. searchCriteriaSwitch(type) {
  176. if (type) {
  177. this.option.height = this.option.height - 46;
  178. } else {
  179. this.option.height = this.option.height + 46;
  180. }
  181. this.$refs.crud.getTableHeight();
  182. },
  183. //点击搜索按钮触发
  184. searchChange(params, done) {
  185. this.page.currentPage = 1;
  186. this.onLoad(this.page, params);
  187. done();
  188. },
  189. refreshChange() {
  190. delete this.search.corpName;
  191. delete this.search.storageName
  192. this.onLoad(this.page, this.search);
  193. },
  194. currentChange(val) {
  195. this.page.currentPage = val;
  196. },
  197. sizeChange(val) {
  198. this.page.currentPage = 1;
  199. this.page.pageSize = val;
  200. },
  201. onLoad(page, params) {
  202. this.loading = true;
  203. this.dataList.forEach(item => {
  204. this.$refs.crud.toggleRowExpansion(item, false);
  205. });
  206. let queryParams = Object.assign({}, params);
  207. if (queryParams.createTime && queryParams.createTime.length > 0) {
  208. queryParams = {
  209. ...queryParams,
  210. beginCreateTime: queryParams.createTime[0] + ' 00:00:00',
  211. endCreateTime: queryParams.createTime[1] + ' 23:59:59',
  212. }
  213. delete queryParams.createTime;
  214. }
  215. getList(
  216. page.currentPage,
  217. page.pageSize,
  218. queryParams
  219. )
  220. .then(res => {
  221. if (res.data.data.records) {
  222. res.data.data.records.forEach(e => {
  223. e.itemLoading = true;
  224. });
  225. }
  226. this.dataList = res.data.data.records ? res.data.data.records : [];
  227. this.page.total = res.data.data.total;
  228. if (this.page.total) {
  229. this.option.height = window.innerHeight - 210;
  230. }
  231. })
  232. .finally(() => {
  233. this.loading = false;
  234. });
  235. },
  236. editOpen(row) {
  237. if (row.billType == "BJ") {
  238. this.$router.push({
  239. path: "/exportTrade/customerInquiry/index",
  240. query: {
  241. id: row.id
  242. }
  243. });
  244. } else {
  245. this.$router.push({
  246. path: "/exportTrade/salesContract/index",
  247. query: {
  248. id: row.id
  249. }
  250. });
  251. }
  252. },
  253. outExport() {
  254. let params = { ...this.search }
  255. if (!params.corpName) this.$set(params, 'corpName', '');
  256. if (!params.orderNo) this.$set(params, 'orderNo', '');
  257. if (!params.gysName) this.$set(params, 'gysName', '');
  258. if (!params.belongCompany) this.$set(params, 'belongCompany', '');
  259. if (params.createTime && params.createTime.length > 0) {
  260. params = {
  261. ...params,
  262. beginCreateTime: params.createTime[0] + ' 00:00:00',
  263. endCreateTime: params.createTime[1] + ' 23:59:59',
  264. }
  265. } else {
  266. params = {
  267. ...params,
  268. beginCreateTime: '',
  269. endCreateTime: '',
  270. }
  271. }
  272. this.$confirm('是否导出数据明细?', '提示', {
  273. confirmButtonText: '确定',
  274. cancelButtonText: '取消',
  275. type: 'warning'
  276. }).then(() => {
  277. window.open(
  278. `/api/blade-purchase-sales/orderitems/dateset-export?${this.website.tokenHeader
  279. }=${getToken()}&corpName=${params.corpName}&beginCreateTime=${params.beginCreateTime}&endCreateTime=${params.endCreateTime}&orderNo=${params.orderNo}&gysName=${params.gysName}&belongCompany=${params.belongCompany}&packageRemarks=${params.packageRemarks}`
  280. );
  281. }).catch(() => {
  282. this.$message({
  283. type: 'info',
  284. message: '已取消' //
  285. });
  286. })
  287. },
  288. //列保存触发
  289. async saveColumn() {
  290. /**
  291. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  292. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  293. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  294. */
  295. const inSave = await this.saveColumnData(
  296. this.getColumnName(127),
  297. this.option
  298. );
  299. if (inSave) {
  300. this.$message.success("保存成功");
  301. //关闭窗口
  302. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  303. this.$nextTick(() => {
  304. this.$refs.crud.doLayout()
  305. })
  306. }
  307. },
  308. async resetColumn() {
  309. this.option = this.defaultOption;
  310. const inSave = await this.delColumnData(this.getColumnName(127), this.defaultOption);
  311. if (inSave) {
  312. this.$nextTick(() => {
  313. this.$refs.crud.doLayout()
  314. })
  315. this.$message.success("重置成功");
  316. //关闭窗口
  317. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  318. }
  319. },
  320. }
  321. };
  322. </script>
  323. <style scoped>
  324. .page-crad ::v-deep .basic-container__card {
  325. height: 94.2vh;
  326. }
  327. ::v-deep .el-table__expanded-cell[class*="cell"] {
  328. padding: 0px;
  329. }
  330. .itemTable ::v-deep .el-table {
  331. width: 100%;
  332. }
  333. </style>