index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. @refresh-change="refreshChange" @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 268)"
  7. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 268)" :page.sync="page">
  8. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  9. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  10. </template>
  11. <template slot-scope="{ row, index }" slot="closingAmount">
  12. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row)">{{ row.closingAmount }}
  13. </span>
  14. </template>
  15. </avue-crud>
  16. </basic-container>
  17. <detailsPage v-if="detailsOpen" @goBack="goBack" :onLoad="form" :detailData="detailData" @backToList="backToList">
  18. </detailsPage>
  19. </div>
  20. </template>
  21. <script>
  22. import { getList, remove } from "@/api/accountsReceivableStatistics";
  23. import detailsPage from "./detailsPage"
  24. import {getToken} from "@/util/auth";
  25. export default {
  26. name: "index",
  27. components: {
  28. detailsPage
  29. },
  30. data() {
  31. return {
  32. detailsOpen: false,
  33. loading: false,
  34. search: {},
  35. form: {},
  36. dataList: [],
  37. detailData: {},
  38. page: {
  39. pageSize: 20,
  40. currentPage: 1,
  41. total: 0,
  42. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  43. },
  44. key: 0,
  45. option: {},
  46. optionList: {
  47. viewBtn: false,
  48. editBtn: false,
  49. delBtn: false,
  50. addBtn: false,
  51. index: true,
  52. span: 8,
  53. border: true,
  54. menu: false,
  55. height: "auto",
  56. searchMenuPosition: "right",
  57. align: "center",
  58. size: "small",
  59. menuWidth: 140,
  60. searchSpan: 8,
  61. searchIcon: true,
  62. searchIndex: 2,
  63. highlightCurrentRow: true,
  64. dialogWidth: "70%",
  65. summaryText: "合计",
  66. showSummary: true,
  67. sumColumnList: [
  68. {
  69. name: 'opening',
  70. type: 'sum',
  71. },
  72. {
  73. name: 'addAmount',
  74. type: 'sum',
  75. },
  76. {
  77. name: 'chargeAmount',
  78. type: 'sum',
  79. },
  80. {
  81. name: 'unpaidAmount',
  82. type: 'sum',
  83. },
  84. ],
  85. column: [{
  86. label: '客户名称',
  87. prop: "customerName",
  88. type: "select",
  89. search: true,
  90. overHidden: true,
  91. props: {
  92. label: 'cname',
  93. value: 'id'
  94. },
  95. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?cname={{key}}&corpType=KH&enableOrNot=0',
  96. }, {
  97. label: '区域',
  98. prop: "region",
  99. overHidden: true,
  100. }, {
  101. label: '业务员',
  102. prop: "salerName",
  103. search: true,
  104. type: 'select',
  105. overHidden: true,
  106. props: {
  107. label: "name",
  108. value: "id"
  109. },
  110. dicUrl: "/api/blade-user/client/getUserByRole",
  111. filterable: true,
  112. }, {
  113. label: '公司',
  114. prop: "salesCompanyId",
  115. hide: true,
  116. showColumn: false,
  117. type: 'select',
  118. search: true,
  119. overHidden: true,
  120. props: {
  121. label: 'fullName',
  122. value: 'id'
  123. },
  124. dicUrl: '/api/blade-system/dept/top-list',
  125. }, {
  126. label: '期初应收',
  127. prop: "opening",
  128. overHidden: true,
  129. }, {
  130. label: '新增',
  131. prop: 'addAmount',
  132. overHidden: true,
  133. }, {
  134. label: '实收',
  135. prop: 'chargeAmount',
  136. overHidden: true,
  137. }, {
  138. label: '未收',
  139. prop: 'unpaidAmount',
  140. overHidden: true,
  141. }, {
  142. label: '业务日期',
  143. prop: "createTime",
  144. searchProp: "createTimeList",
  145. type: "date",
  146. overHidden: true,
  147. search: true,
  148. hide: true,
  149. showColumn: false,
  150. search: true,
  151. width: 100,
  152. searchRange: true,
  153. searchDefaultTime: ["00:00:00", "23:59:59"],
  154. format: "yyyy-MM-dd HH:mm:ss",
  155. valueFormat: "yyyy-MM-dd HH:mm:ss"
  156. }, {
  157. label: '期末',
  158. prop: "closingAmount",
  159. overHidden: true,
  160. }]
  161. }
  162. }
  163. },
  164. async created() {
  165. this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  166. this.key++
  167. let i = 0;
  168. this.option.column.forEach(item => {
  169. if (item.search) i++
  170. })
  171. if (i % 3 !== 0) {
  172. const num = 3 - Number(i % 3)
  173. this.option.searchMenuSpan = num * 8;
  174. this.option.searchMenuPosition = "right";
  175. }
  176. this.refreshChange()
  177. },
  178. methods: {
  179. // 导出
  180. outExport() {
  181. console.log(this.search,412)
  182. let config = { params: { ...this.search } }
  183. if (config.params) {
  184. for (const propName of Object.keys(config.params)) {
  185. const value = config.params[propName];
  186. if (value !== null && typeof (value) !== "undefined") {
  187. if (value instanceof Array) {
  188. for (const key of Object.keys(value)) {
  189. let params = propName + '[' + key + ']';
  190. config.params[params] = value[key]
  191. }
  192. delete config.params[propName]
  193. }
  194. }
  195. }
  196. }
  197. const routeData = this.$router.resolve({
  198. path: '/api/blade-sales-part/order/collectionExport', //跳转目标下载地址
  199. query: {
  200. ...config.params //括号内是要传递给新窗口的参数
  201. }
  202. })
  203. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  204. },
  205. check(row) {
  206. this.form = row
  207. this.detailsOpen = true
  208. },
  209. backToList(type) {
  210. this.form = {}
  211. this.detailsOpen = false
  212. if (type === 0) {
  213. this.detailData = {}
  214. }
  215. this.onLoad(this.page, this.search)
  216. },
  217. //刷新
  218. refreshChange() {
  219. this.onLoad(this.page, this.search)
  220. },
  221. rowDel(form, index) {
  222. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  223. confirmButtonText: '确定',
  224. cancelButtonText: '取消',
  225. type: 'warning'
  226. }).then(() => {
  227. remove(form.id).then(res => {
  228. this.$message({
  229. type: 'success',
  230. message: '删除成功!'
  231. });
  232. this.dataList.splice(index, 1);
  233. this.onLoad(this.page)
  234. })
  235. }).catch(() => {
  236. });
  237. },
  238. searchChange(params, done) {
  239. done();
  240. this.onLoad(this.page, params)
  241. },
  242. onLoad(page, params = {}) {
  243. this.search.customerId = this.search.customerName
  244. params = {
  245. ...params,
  246. current: page.currentPage,
  247. size: page.pageSize,
  248. ...Object.assign(params, this.search)
  249. }
  250. this.loading = true
  251. getList(params).then(res => {
  252. this.dataList = res.data.data.records
  253. this.page.total = res.data.data.total
  254. this.loading = false
  255. }).finally(() => {
  256. this.loading = false
  257. })
  258. },
  259. editOpen(row, status) {
  260. console.log('1111');
  261. this.form = row
  262. console.log(this.form);
  263. this.detailData = {
  264. id: row.customerId,
  265. status: status
  266. };
  267. this.detailsOpen = true;
  268. },
  269. //自定义列保存
  270. async saveColumnTwo(ref, option, optionBack, code) {
  271. /**
  272. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  273. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  274. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  275. */
  276. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  277. if (inSave) {
  278. this.$message.success("保存成功");
  279. //关闭窗口
  280. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  281. }
  282. },
  283. //自定义列重置
  284. async resetColumnTwo(ref, option, optionBack, code) {
  285. this[option] = this[optionBack];
  286. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  287. if (inSave) {
  288. this.$message.success("重置成功");
  289. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  290. }
  291. }
  292. }
  293. }
  294. </script>
  295. <style scoped></style>