index.vue 9.3 KB

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