index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <basic-container>
  3. <avue-crud :key="key" ref="crud" :option="option" :data="data" :search.sync="query" @on-load="onLoad"
  4. @search-reset="resetChange" :page.sync="page" :cell-style="cellStyle" @search-change="searchChange"
  5. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 369)"
  6. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 369)">
  7. <template slot="menuLeft">
  8. <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>
  9. </template>
  10. <template slot="header">
  11. <el-table :data="commodityData" border size="small" @header-click="cellClick" style="width: 100%">
  12. <el-table-column v-for="(item, index) in commodityLabel" :key="index" :prop="item.prop"
  13. show-overflow-tooltip :label="item.label" />
  14. </el-table>
  15. </template>
  16. <template slot="customerNameSearch">
  17. <search-query :datalist="customerData" :selectValue="query.customerName" :filterable="true"
  18. :clearable="true" :remote="true" :buttonIf="false"
  19. :forParameter="{ key: 'id', label: 'cname', value: 'cname' }" placeholder="请选择客户名称"
  20. @remoteMethod="KHgetListfun" @corpFocus="KHgetListfun" @corpChange="corpChange($event, 'customerName')">
  21. </search-query>
  22. </template>
  23. <template slot="storageIdSearch">
  24. <search-query :datalist="storageData" :selectValue="query.storageId" :clearable="true" :buttonIf="false"
  25. :forParameter="{ key: 'id', label: 'cname', value: 'id' }" placeholder="请选择仓库" @corpFocus="storageIdfun"
  26. @corpChange="corpChange($event, 'storageId')">
  27. </search-query>
  28. </template>
  29. <template slot="salerNameSearch">
  30. <search-query :datalist="salerData" :selectValue="query.salerName" :clearable="true" :buttonIf="false"
  31. :forParameter="{ key: 'id', label: 'name', value: 'name' }" placeholder="请选择业务员"
  32. @corpFocus="YWYgetListfun" @corpChange="corpChange($event, 'salerName')">
  33. </search-query>
  34. </template>
  35. </avue-crud>
  36. </basic-container>
  37. </template>
  38. <script>
  39. import { getList, salespersonCustomerSum } from "@/api/tirePartsMall/salesAnalysis";
  40. import { defaultDate3 } from "@/util/date";
  41. import { getList as KHgetList } from '@/api/tirePartsMall/basicData/customerInformation/index'
  42. import SearchQuery from "@/components/iosbasic-data/searchquery.vue";
  43. import { getToken } from "@/util/auth";
  44. import { getSalesman } from "@/api/landTransportation";
  45. import { storageDesc } from "@/api/tirePartsMall/basicData/listingManagement";
  46. export default {
  47. components: { SearchQuery },
  48. data() {
  49. return {
  50. key: 0,
  51. data: [],
  52. total: [],
  53. storageData: [],
  54. query: {
  55. businesDateStart: defaultDate3()[0],
  56. businesDateEnd: defaultDate3()[1],
  57. bsType: 1
  58. },
  59. page: {
  60. pageSize: 10,
  61. currentPage: 1,
  62. total: 0,
  63. pageSizes: [10, 50, 100, 200, 300]
  64. },
  65. option: {},
  66. optionList: {
  67. align: 'center',
  68. stripe: true,
  69. index: true,
  70. menu: false,
  71. height: "auto",
  72. border: true,
  73. searchMenuSpan: 12,
  74. addBtn: false,
  75. showSummary: true,
  76. summaryText: "合计",
  77. sumColumnList: [
  78. {
  79. name: 'salesQuantity',
  80. type: 'sum',
  81. decimals: 0
  82. },
  83. {
  84. name: 'returnQuantity',
  85. type: 'sum',
  86. decimals: 0
  87. },
  88. {
  89. name: 'salesAmount',
  90. type: 'sum',
  91. decimals: 2
  92. },
  93. {
  94. name: 'returnAmount',
  95. type: 'sum',
  96. decimals: 2
  97. },
  98. {
  99. name: 'salesProfit',
  100. type: 'sum',
  101. decimals: 2
  102. }
  103. ],
  104. column: [{
  105. label: '业务开始',
  106. prop: 'businesDateStart',
  107. overHidden: true,
  108. search: true,
  109. hide: true,
  110. searchOrder: 1,
  111. type: "date",
  112. format: "yyyy-MM-dd",
  113. valueFormat: "yyyy-MM-dd",
  114. },
  115. {
  116. label: '业务结束',
  117. prop: 'businesDateEnd',
  118. overHidden: true,
  119. search: true,
  120. hide: true,
  121. searchOrder: 2,
  122. type: "date",
  123. format: "yyyy-MM-dd",
  124. valueFormat: "yyyy-MM-dd",
  125. },
  126. {
  127. label: '业务员',
  128. prop: 'salerName',
  129. overHidden: true,
  130. search: true,
  131. searchslot: true,
  132. hide: true,
  133. searchOrder: 3
  134. },
  135. {
  136. label: '客户名称',
  137. prop: 'customerName',
  138. overHidden: true,
  139. search: true,
  140. searchslot: true,
  141. hide: true,
  142. searchOrder: 4
  143. },
  144. {
  145. label: '仓库',
  146. prop: 'storageName',
  147. searchProp: "storageId",
  148. search: true,
  149. overHidden: true,
  150. searchslot: true,
  151. hide: true,
  152. searchOrder: 5
  153. },
  154. {
  155. label: '业务类型',
  156. prop: "bsType",
  157. type: 'select',
  158. search: true,
  159. overHidden: true,
  160. searchslot: true,
  161. hide: true,
  162. searchOrder: 6,
  163. dicData: [{
  164. label: '客户',
  165. value: 1
  166. }, {
  167. label: '业务员',
  168. value: 2
  169. }],
  170. },
  171. {
  172. label: '分析对象',
  173. prop: 'customerName',
  174. overHidden: true,
  175. },
  176. {
  177. label: '销售数量',
  178. prop: 'salesQuantity',
  179. overHidden: true,
  180. }, {
  181. label: '退货数量',
  182. prop: 'returnQuantity',
  183. overHidden: true,
  184. }, {
  185. label: '销售金额',
  186. prop: 'salesAmount',
  187. overHidden: true,
  188. }, {
  189. label: '退货金额',
  190. prop: 'returnAmount',
  191. overHidden: true,
  192. },
  193. {
  194. label: '销售利润',
  195. prop: 'salesProfit',
  196. overHidde: true,
  197. }],
  198. },
  199. customerData: [], // 客户数据
  200. salerData: [], // 业务员
  201. commodityData: [], // 合计数据
  202. // 合计的配置项
  203. commodityLabel: [{
  204. id: 1,
  205. label: '销售数量',
  206. prop: 'salesQuantity',
  207. }, {
  208. id: 2,
  209. label: '退货数量',
  210. prop: 'returnQuantity'
  211. }, {
  212. id: 3,
  213. label: '销售金额',
  214. prop: 'salesAmount',
  215. }, {
  216. id: 4,
  217. label: '退货金额',
  218. prop: 'returnAmount'
  219. }, {
  220. id: 5,
  221. label: '销售利润',
  222. prop: 'salesProfit'
  223. }],
  224. }
  225. },
  226. async created() {
  227. this.option = await this.getColumnData(this.getColumnName(369), this.optionList);
  228. },
  229. methods: {
  230. resetChange() {
  231. this.query = this.$options.data().query
  232. },
  233. cellStyle({ row, rowIndex }) {
  234. if (row.status == '已取消') {
  235. return 'color: red';
  236. }
  237. return
  238. },
  239. //导出
  240. outExport() {
  241. let config = { params: { ...this.query } }
  242. if (config.params) {
  243. for (const propName of Object.keys(config.params)) {
  244. const value = config.params[propName];
  245. if (value !== null && typeof (value) !== "undefined") {
  246. if (value instanceof Array) {
  247. for (const key of Object.keys(value)) {
  248. let params = propName + '[' + key + ']';
  249. config.params[params] = value[key]
  250. }
  251. delete config.params[propName]
  252. }
  253. }
  254. }
  255. }
  256. const routeData = this.$router.resolve({
  257. path: '/api/blade-sales-part/statistics/salespersonCustomerExport', //跳转目标窗口的地址
  258. query: {
  259. ...config.params, //括号内是要传递给新窗口的参数,
  260. }
  261. })
  262. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  263. },
  264. storageIdfun() {
  265. storageDesc().then(res => {
  266. this.storageData = res.data.data
  267. })
  268. },
  269. // 获取客户数据
  270. KHgetListfun(cname) {
  271. KHgetList({ current: 1, size: 20, corpType: 'KH', cname: cname ? cname : null }).then(res => {
  272. this.customerData = res.data.data.records
  273. })
  274. },
  275. // 获取业务员数据
  276. YWYgetListfun(realName) {
  277. // YWYgetList(1,10,{realName:realName?realName:null}).then(res=>{
  278. // this.salerData = res.data.data.records
  279. // })
  280. getSalesman().then(res => {
  281. this.salerData = res.data.data
  282. })
  283. },
  284. // 下拉回调
  285. corpChange(value, name) {
  286. this.$set(this.query, name, value)
  287. },
  288. //搜索
  289. searchChange(params, done) {
  290. this.query = params;
  291. this.onLoad(this.page, params)
  292. done();
  293. },
  294. // 获取列表数据
  295. onLoad(page, params = {}) {
  296. let queryParams = {
  297. size: page.pageSize,
  298. current: page.currentPage,
  299. ...Object.assign(params, this.query)
  300. }
  301. console.log(queryParams)
  302. getList(queryParams).then(res => {
  303. this.data = res.data.data.records
  304. this.page.total = res.data.data.total
  305. salespersonCustomerSum({ ...Object.assign(params, this.query) }).then(re => {
  306. this.commodityData = [re.data.data]
  307. })
  308. })
  309. },
  310. //自定义列保存
  311. async saveColumnTwo(ref, option, optionBack, code) {
  312. /**
  313. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  314. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  315. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  316. */
  317. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  318. if (inSave) {
  319. this.$message.success("保存成功");
  320. //关闭窗口
  321. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  322. }
  323. },
  324. //自定义列重置
  325. async resetColumnTwo(ref, option, optionBack, code) {
  326. this[option] = this[optionBack];
  327. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  328. if (inSave) {
  329. this.$message.success("重置成功");
  330. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  331. }
  332. },
  333. }
  334. }
  335. </script>
  336. <style scoped></style>