index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. // {
  98. // label: '区域',
  99. // prop: "region",
  100. // overHidden: true,
  101. // },
  102. {
  103. label: '业务员',
  104. prop: "salerName",
  105. search: true,
  106. type: 'select',
  107. overHidden: true,
  108. props: {
  109. label: "name",
  110. value: "id"
  111. },
  112. dicUrl: "/api/blade-user/client/salerList",
  113. filterable: true,
  114. }, {
  115. label: '公司',
  116. prop: "salesCompanyId",
  117. hide: true,
  118. showColumn: false,
  119. type: 'select',
  120. search: true,
  121. overHidden: true,
  122. props: {
  123. label: 'fullName',
  124. value: 'id'
  125. },
  126. dicUrl: '/api/blade-system/dept/top-list',
  127. }, {
  128. label: '期初应收',
  129. prop: "opening",
  130. overHidden: true,
  131. }, {
  132. label: '新增(本期)',
  133. prop: 'addAmount',
  134. overHidden: true,
  135. }, {
  136. label: '实收(本期)',
  137. prop: 'chargeAmount',
  138. overHidden: true,
  139. }, {
  140. label: '未收(本期)',
  141. prop: 'unpaidAmount',
  142. overHidden: true,
  143. }, {
  144. label: '业务日期',
  145. prop: "businesDateList",
  146. // searchProp: "businesDateList",
  147. type: "monthrange",
  148. format: "yyyy-MM",
  149. valueFormat: "yyyy-MM",
  150. unlinkPanels: true,
  151. searchRange: true,
  152. overHidden: true,
  153. search: true,
  154. hide: true,
  155. // showColumn: false,
  156. width: 100,
  157. // searchDefaultTime: ["00:00:00", "23:59:59"],
  158. // format: "yyyy-MM-dd HH:mm:ss",
  159. // valueFormat: "yyyy-MM-dd HH:mm:ss"
  160. }, {
  161. label: '期末',
  162. prop: "closingAmount",
  163. overHidden: true,
  164. }]
  165. }
  166. }
  167. },
  168. async created() {
  169. this.option = await this.getColumnData(this.getColumnName(268), this.optionList);
  170. this.key++
  171. let i = 0;
  172. this.option.column.forEach(item => {
  173. if (item.search) i++
  174. })
  175. if (i % 3 !== 0) {
  176. const num = 3 - Number(i % 3)
  177. this.option.searchMenuSpan = num * 8;
  178. this.option.searchMenuPosition = "right";
  179. }
  180. this.refreshChange()
  181. },
  182. methods: {
  183. // 导出
  184. outExport() {
  185. console.log(this.search,412)
  186. let config = { params: { ...this.search } }
  187. if (config.params) {
  188. for (const propName of Object.keys(config.params)) {
  189. const value = config.params[propName];
  190. if (value !== null && typeof (value) !== "undefined") {
  191. if (value instanceof Array) {
  192. for (const key of Object.keys(value)) {
  193. let params = propName + '[' + key + ']';
  194. config.params[params] = value[key]
  195. }
  196. delete config.params[propName]
  197. }
  198. }
  199. }
  200. }
  201. const routeData = this.$router.resolve({
  202. path: '/api/blade-sales-part/order/collectionExport', //跳转目标下载地址
  203. query: {
  204. ...config.params //括号内是要传递给新窗口的参数
  205. }
  206. })
  207. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  208. },
  209. check(row) {
  210. this.form = row
  211. this.detailsOpen = true
  212. },
  213. backToList(type) {
  214. this.form = {}
  215. this.detailsOpen = false
  216. if (type === 0) {
  217. this.detailData = {}
  218. }
  219. this.onLoad(this.page, this.search)
  220. },
  221. //刷新
  222. refreshChange() {
  223. this.onLoad(this.page, this.search)
  224. },
  225. rowDel(form, index) {
  226. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  227. confirmButtonText: '确定',
  228. cancelButtonText: '取消',
  229. type: 'warning'
  230. }).then(() => {
  231. remove(form.id).then(res => {
  232. this.$message({
  233. type: 'success',
  234. message: '删除成功!'
  235. });
  236. this.dataList.splice(index, 1);
  237. this.onLoad(this.page)
  238. })
  239. }).catch(() => {
  240. });
  241. },
  242. searchChange(params, done) {
  243. this.page.currentPage = 1;
  244. done();
  245. this.onLoad(this.page, params)
  246. },
  247. onLoad(page, params = {}) {
  248. this.search.customerId = this.search.customerName
  249. params = {
  250. ...params,
  251. current: page.currentPage,
  252. size: page.pageSize,
  253. ...Object.assign(params, this.search)
  254. }
  255. this.loading = true
  256. getList(params).then(res => {
  257. this.dataList = res.data.data.records
  258. this.page.total = res.data.data.total
  259. this.loading = false
  260. }).finally(() => {
  261. this.loading = false
  262. })
  263. },
  264. editOpen(row, status) {
  265. console.log('1111');
  266. this.form = row
  267. console.log(this.form);
  268. this.detailData = {
  269. id: row.customerId,
  270. status: status
  271. };
  272. this.detailsOpen = true;
  273. },
  274. //自定义列保存
  275. async saveColumnTwo(ref, option, optionBack, code) {
  276. /**
  277. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  278. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  279. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  280. */
  281. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  282. if (inSave) {
  283. this.$message.success("保存成功");
  284. //关闭窗口
  285. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  286. }
  287. },
  288. //自定义列重置
  289. async resetColumnTwo(ref, option, optionBack, code) {
  290. this[option] = this[optionBack];
  291. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  292. if (inSave) {
  293. this.$message.success("重置成功");
  294. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  295. }
  296. }
  297. }
  298. }
  299. </script>
  300. <style scoped></style>