index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  5. ref="crud" :key="key" @on-load="onLoad" @search-change="searchChange" @row-del="rowDel"
  6. @expand-change="expandChange" @refresh-change="refreshChange"
  7. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 405)"
  8. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 405)" :page.sync="page">
  9. <template slot-scope="{type,size,row,index}" slot="menu">
  10. <el-button :size="size" :disabled="row.status==1" :type="type" @click="$refs.crud.rowDel(row, index)">删除</el-button>
  11. </template>
  12. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  13. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新建</el-button>
  14. </template>
  15. <template slot-scope="{ row, index }" slot="confirmingPersonName">
  16. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.confirmingPersonName }}
  17. </span>
  18. </template>
  19. <template slot-scope="{ row, index }" slot="sysNo">
  20. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.sysNo }}
  21. </span>
  22. </template>
  23. </avue-crud>
  24. </basic-container>
  25. <detailsPage v-if="detailsOpen" @goBack="goBack" :onLoad="form" :detailData="detailData" @backToList="backToList">
  26. </detailsPage>
  27. </div>
  28. </template>
  29. <script>
  30. import { getList, remove } from "@/api/tirePartsMall/financingManagement/balanceRecharge";
  31. import detailsPage from "./detailsPage"
  32. import { getDetails } from "@/api/tirePartsMall/salesService/saleOrder";
  33. import { getToken } from "@/util/auth";
  34. export default {
  35. name: "index",
  36. components: {
  37. detailsPage
  38. },
  39. data() {
  40. return {
  41. detailsOpen: false,
  42. loading: false,
  43. search: {},
  44. form: {},
  45. dataList: [],
  46. detailData: {},
  47. page: {
  48. pageSize: 20,
  49. currentPage: 1,
  50. total: 0,
  51. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  52. },
  53. key: 0,
  54. option: {},
  55. optionList: {
  56. viewBtn: false,
  57. editBtn: false,
  58. delBtn: false,
  59. addBtn: false,
  60. index: true,
  61. span: 6,
  62. border: true,
  63. height: "auto",
  64. searchMenuPosition: "right",
  65. align: "center",
  66. size: "small",
  67. menuWidth: 50,
  68. searchSpan: 6,
  69. searchMenuSpan: 24,
  70. searchIcon: true,
  71. // expand: true,
  72. // expandWidth: 60,
  73. searchIndex: 3,
  74. highlightCurrentRow: true,
  75. dialogWidth: "70%",
  76. summaryText: "合计",
  77. showSummary: true,
  78. sumColumnList: [
  79. {
  80. name: 'amount',
  81. type: 'sum',
  82. decimals: 2,
  83. }],
  84. column: [
  85. {
  86. label: '确认人',
  87. prop: "confirmingPersonName",
  88. search: true,
  89. overHidden: true,
  90. type: 'select',
  91. filterable: true,
  92. remote: true,
  93. props: {
  94. label: 'cname',
  95. value: 'cname',
  96. res: 'data.records'
  97. },
  98. dicUrl: '/api/blade-sales-part/corpsDesc/list?current=1&size=20&corpType=GYS&cname={{key}}',
  99. },
  100. {
  101. label: '单号',
  102. prop: "sysNo",
  103. overHidden: true,
  104. },
  105. {
  106. label: '金额',
  107. prop: "amount",
  108. overHidden: true,
  109. },
  110. {
  111. label: '状态',
  112. prop: "status",
  113. type: 'select',
  114. dicData: [{
  115. label: '已确认',
  116. value: 1
  117. }, {
  118. label: '录入',
  119. value: 0
  120. }],
  121. overHidden: true,
  122. },
  123. {
  124. label: "确认时间",
  125. prop: "confirmingPersonDate",
  126. searchProp: "confirmingPersonDateList",
  127. type: "date",
  128. search: true,
  129. overHidden: true,
  130. searchRange: true,
  131. unlinkPanels: true,
  132. searchDefaultTime: ["00:00:00", "23:59:59"],
  133. format: "yyyy-MM-dd HH:mm:ss",
  134. valueFormat: "yyyy-MM-dd HH:mm:ss"
  135. },
  136. {
  137. label: "制单人",
  138. prop: "createUserName",
  139. searchProp: "createUser",
  140. search: true,
  141. overHidden: true,
  142. filterable: true,
  143. remote: true,
  144. type: "select",
  145. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  146. props: {
  147. label: "account",
  148. value: "id",
  149. res: 'data.records'
  150. }
  151. },
  152. {
  153. label: "制单日期",
  154. prop: "createTime",
  155. searchProp: "createTimeList",
  156. type: "date",
  157. search: true,
  158. overHidden: true,
  159. searchRange: true,
  160. unlinkPanels: true,
  161. searchDefaultTime: ["00:00:00", "23:59:59"],
  162. format: "yyyy-MM-dd",
  163. valueFormat: "yyyy-MM-dd HH:mm:ss"
  164. },
  165. {
  166. label: "更新人",
  167. prop: "updateUserName",
  168. searchProp: "updateUser",
  169. overHidden: true,
  170. filterable: true,
  171. remote: true,
  172. type: "select",
  173. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  174. props: {
  175. label: "account",
  176. value: "id",
  177. res: 'data.records'
  178. }
  179. },
  180. {
  181. label: "更新日期",
  182. prop: "updateTime",
  183. searchProp: "updateTimeList",
  184. type: "date",
  185. overHidden: true,
  186. searchRange: true,
  187. searchDefaultTime: ["00:00:00", "23:59:59"],
  188. format: "yyyy-MM-dd",
  189. valueFormat: "yyyy-MM-dd HH:mm:ss"
  190. }
  191. ]
  192. }
  193. }
  194. },
  195. activated() {
  196. setTimeout(() => {
  197. if (this.$route.query.srcId) {
  198. this.$store.commit("IN_BALANCE_DETAIL");
  199. this.detailsOpen = true;
  200. }
  201. }, 100);
  202. },
  203. async created() {
  204. this.option = await this.getColumnData(this.getColumnName(405), this.optionList);
  205. this.key++
  206. let i = 0;
  207. this.option.column.forEach(item => {
  208. if (item.search) i++
  209. })
  210. // if (i % 3 !== 0) {
  211. // const num = 3 - Number(i % 3)
  212. // this.option.searchMenuSpan = num * 8;
  213. // this.option.searchMenuPosition = "right";
  214. // }
  215. },
  216. methods: {
  217. // 导出
  218. outExport() {
  219. let config = { params: { ...this.search } }
  220. if (config.params) {
  221. for (const propName of Object.keys(config.params)) {
  222. const value = config.params[propName];
  223. if (value !== null && typeof (value) !== "undefined") {
  224. if (value instanceof Array) {
  225. for (const key of Object.keys(value)) {
  226. let params = propName + '[' + key + ']';
  227. config.params[params] = value[key]
  228. }
  229. delete config.params[propName]
  230. }
  231. }
  232. }
  233. }
  234. const routeData = this.$router.resolve({
  235. path: '/api/blade-sales-part/returns/listExport', //跳转目标下载地址
  236. query: {
  237. ...config.params //括号内是要传递给新窗口的参数
  238. }
  239. })
  240. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  241. },
  242. check(row) {
  243. this.form = row
  244. this.detailsOpen = true
  245. },
  246. backToList(type) {
  247. this.form = {}
  248. this.detailsOpen = false
  249. if (type === 0) {
  250. this.detailData = {}
  251. }
  252. if (this.$route.query.srcId) {
  253. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  254. this.$router.push({
  255. path: "/tirePartsMall/financingManagement/balanceRecharge/index"
  256. });
  257. }
  258. this.onLoad(this.page, this.search)
  259. this.$store.commit("OUT_BALANCE_DETAIL");
  260. },
  261. editOpen(row, status) {
  262. this.form = row
  263. this.detailData = {
  264. id: row.id,
  265. status: status
  266. };
  267. this.$store.commit("IN_BALANCE_DETAIL");
  268. this.detailsOpen = true;
  269. },
  270. //刷新
  271. refreshChange() {
  272. this.onLoad(this.page, this.search)
  273. },
  274. expandChange(row) {
  275. if (!row.itemData) {
  276. getDetails({ id: row.id })
  277. .then(res => {
  278. this.dataList[row.$index].itemData = res.data.data.orderItemsList;
  279. })
  280. .finally(() => {
  281. this.dataList[row.$index].itemLoading = false;
  282. });
  283. }
  284. },
  285. rowDel(form, index) {
  286. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  287. confirmButtonText: '确定',
  288. cancelButtonText: '取消',
  289. type: 'warning'
  290. }).then(() => {
  291. remove({ ids: form.id }).then(res => {
  292. this.$message({
  293. type: 'success',
  294. message: '删除成功!'
  295. });
  296. this.dataList.splice(index, 1);
  297. this.onLoad(this.page)
  298. })
  299. }).catch(() => {
  300. });
  301. },
  302. searchChange(params, done) {
  303. this.page.currentPage = 1
  304. done();
  305. this.onLoad(this.page, params)
  306. },
  307. onLoad(page, params = {}) {
  308. params = {
  309. ...params,
  310. current: page.currentPage,
  311. size: page.pageSize,
  312. ...Object.assign(params, this.search)
  313. }
  314. this.loading = true
  315. this.dataList.forEach(item => {
  316. this.$refs.crud.toggleRowExpansion(item, false);
  317. });
  318. getList(params).then(res => {
  319. if (res.data.data.records) {
  320. res.data.data.records.forEach(e => {
  321. e.itemLoading = true;
  322. });
  323. }
  324. this.dataList = res.data.data.records
  325. this.page.total = res.data.data.total
  326. this.$nextTick(() => {
  327. this.$refs.crud.doLayout()
  328. this.$refs.crud.dicInit()
  329. })
  330. }).finally(() => {
  331. this.loading = false
  332. })
  333. },
  334. //自定义列保存
  335. async saveColumnTwo(ref, option, optionBack, code) {
  336. /**
  337. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  338. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  339. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  340. */
  341. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  342. if (inSave) {
  343. this.$message.success("保存成功");
  344. //关闭窗口
  345. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  346. }
  347. },
  348. //自定义列重置
  349. async resetColumnTwo(ref, option, optionBack, code) {
  350. this[option] = this[optionBack];
  351. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  352. if (inSave) {
  353. this.$message.success("重置成功");
  354. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  355. }
  356. }
  357. }
  358. }
  359. </script>
  360. <style scoped>
  361. .itemTable ::v-deep .el-table {
  362. margin-left: 50px;
  363. width: 100%;
  364. }
  365. .bottomBox {
  366. padding: 3px 6px;
  367. border-radius: 12px;
  368. color: #fff;
  369. font-size: 10px;
  370. }
  371. /deep/ .el-col-md-8 {
  372. width: 24.33333%;
  373. }
  374. </style>