index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"
  7. @save="corpTypeVisible = true">
  8. <template slot="addBtn">
  9. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  10. <i class="el-icon-setting" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"
  11. @click="corpTypeVisible = true"></i>
  12. </el-tooltip>
  13. </template>
  14. </avue-tree>
  15. </el-col>
  16. <el-col :span="20">
  17. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
  18. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  19. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  20. @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
  21. <template slot="menuLeft">
  22. <el-button type="primary" size="mini" @click.stop="newAdd()">新建客户
  23. </el-button>
  24. <el-button type="primary" size="mini" icon="el-icon-bottom" @click="excelBox = true">导入
  25. </el-button>
  26. <el-button type="primary" size="mini" icon="el-icon-top" @click="outExport">导出
  27. </el-button>
  28. </template>
  29. <template slot-scope="{ row, index }" slot="cname">
  30. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.cname }}</span>
  31. </template>
  32. <!--<template slot="idsSearch">-->
  33. <!-- <crop-select v-model="search.ids" corpType="KH"></crop-select>-->
  34. <!--</template>-->
  35. <template slot="dateSearch">
  36. <el-date-picker v-model="search.date" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期"
  37. format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']"
  38. :picker-options="pickerOptions">
  39. </el-date-picker>
  40. </template>
  41. <template slot-scope="{type,size, row, index }" slot="menu">
  42. <el-button :size="size" :type="type" :disabled="!row.enableOrNot" @click="editOpen(row, 2)">编辑</el-button>
  43. <el-button :size="size" :type="type" :disabled="!row.enableOrNot" @click.stop="rowDel(row)">删除</el-button>
  44. </template>
  45. <!-- <template slot="deliveryWarehouseName">
  46. <el-select v-model="search.deliveryWarehouseName" filterable clearable size="small" :disabled="disabled">
  47. <el-option v-for="(item, index) in WarehouseNameList" :key="index" :label="item.cname" :value="item.id">
  48. </el-option>
  49. </el-select>
  50. </template> -->
  51. </avue-crud>
  52. </el-col>
  53. </el-row>
  54. </basic-container>
  55. <details-page v-if="!show" @goBack="goBack()" :detailData="detailData" />
  56. <!--<details-info v-if="!showInfo" @goBack="goBack()" @editOpen="editOpen" :detailData="detailData" />-->
  57. <el-dialog title="设置客户分类" v-dialogDrag :visible.sync="corpTypeVisible" class="avue-dialog" width="80%" append-to-body
  58. @closed="corpTypeClosed">
  59. <span>
  60. <corp-type></corp-type>
  61. <!-- <avue-form :key="reload" ref="corpType" v-model="form4" :option="option4" style="margin-top:20px">
  62. </avue-form> -->
  63. </span>
  64. <div class="avue-dialog__footer">
  65. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  66. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  67. </div>
  68. </el-dialog>
  69. <el-dialog title="导入客户" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  70. v-dialog-drag>
  71. <avue-form :option="excelOption" v-model="excelForm" table-loading="excelLoading" :upload-before="uploadBefore"
  72. :upload-after="uploadAfter">
  73. <template slot="excelTemplate">
  74. <el-button type="primary" @click="derivation">
  75. 点击下载<i class="el-icon-download el-icon--right"></i>
  76. </el-button>
  77. </template>
  78. </avue-form>
  79. <p style="text-align: center;color: #DC0505">
  80. 温馨提示 第一次导入时请先下载模板
  81. </p>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import detailsPage from "./detailsPage";
  87. import { option } from "./js/optionList";
  88. import {customerListAll} from '@/api/tirePartsMall/basicData/warehouse'
  89. import {
  90. getList,
  91. getCorpType,
  92. pageStatistics,
  93. remove,
  94. customerList
  95. } from "@/api/tirePartsMall/basicData/customerInformation";
  96. import corpType from './components/index.vue'
  97. import { getToken } from "@/util/auth";
  98. export default {
  99. name: "index",
  100. data() {
  101. return {
  102. corpTypeVisible: false,
  103. excelForm: {},
  104. WarehouseNameList:[],
  105. excelOption: {
  106. submitBtn: false,
  107. emptyBtn: false,
  108. column: [
  109. {
  110. label: "模板下载",
  111. prop: "excelTemplate",
  112. formslot: true,
  113. span: 24
  114. },
  115. {
  116. label: "导入客户",
  117. prop: "excelFile",
  118. type: "upload",
  119. drag: true,
  120. loadText: "客户上传中,请稍等",
  121. accept: '.xls,.xlsx',
  122. span: 24,
  123. propsHttp: {
  124. res: "data"
  125. },
  126. tip: "请上传 .xls,.xlsx 标准格式文件",
  127. action: "/api/blade-sales-part/corpsDesc/corpsImport"
  128. }
  129. ]
  130. },
  131. src: '',
  132. show: true,
  133. excelBox: false,
  134. loading: false,
  135. search: {},
  136. detailData: {},
  137. dataList: [],
  138. selectionList: [],
  139. page: {
  140. pageSize: 20,
  141. currentPage: 1,
  142. total: 0,
  143. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  144. },
  145. form: {
  146. debitAmount: 0,
  147. deliveringAmount: 0,
  148. advancePayment: 0,
  149. balanceAmount: 0,
  150. settlmentAmount: 0
  151. },
  152. formSerach: {},
  153. pickerOptions: {
  154. shortcuts: [
  155. {
  156. text: '当天',
  157. onClick(picker) {
  158. const date = new Date();
  159. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  160. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  161. picker.$emit('pick', [start, end]);
  162. }
  163. },
  164. {
  165. text: '昨天',
  166. onClick(picker) {
  167. const date = new Date();
  168. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, 0, 0, 0);
  169. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, 23, 59, 59);
  170. picker.$emit('pick', [start, end]);
  171. }
  172. }, {
  173. text: '当月',
  174. onClick(picker) {
  175. const date = new Date();
  176. const start = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
  177. const end = new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59);
  178. picker.$emit('pick', [start, end]);
  179. }
  180. }, {
  181. text: '当季',
  182. onClick(picker) {
  183. const date = new Date();
  184. const start = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3, 1, 0, 0, 0);
  185. const end = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3 + 3, 0, 23, 59, 59);
  186. picker.$emit('pick', [start, end]);
  187. }
  188. }, {
  189. text: '当年',
  190. onClick(picker) {
  191. const date = new Date();
  192. const start = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
  193. const end = new Date(date.getFullYear() + 1, 0, 0, 23, 59, 59);
  194. picker.$emit('pick', [start, end]);
  195. }
  196. }, {
  197. text: '最近一周',
  198. onClick(picker) {
  199. const date = new Date();
  200. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7, 0, 0, 0);
  201. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  202. picker.$emit('pick', [start, end]);
  203. }
  204. }, {
  205. text: '最近二周',
  206. onClick(picker) {
  207. const date = new Date();
  208. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 2, 0, 0, 0);
  209. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  210. picker.$emit('pick', [start, end]);
  211. }
  212. }, {
  213. text: '最近三周',
  214. onClick(picker) {
  215. const date = new Date();
  216. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 3, 0, 0, 0);
  217. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  218. picker.$emit('pick', [start, end]);
  219. }
  220. }]
  221. },
  222. treeOption: {
  223. addBtn: false,
  224. menu: false,
  225. size: "small",
  226. props: {
  227. labelText: "标题",
  228. label: "title",
  229. value: "value",
  230. }
  231. },
  232. treeData: [],
  233. form4: {},
  234. option4: {
  235. menuBtn: false,
  236. labelWidth: 80,
  237. column: [
  238. {
  239. label: "分类名称",
  240. prop: "cname",
  241. rules: [
  242. {
  243. required: true,
  244. message: "",
  245. trigger: "blur"
  246. }
  247. ],
  248. span: 24,
  249. },
  250. {
  251. label: "上级类型",
  252. prop: "parentId",
  253. dicData: [],
  254. type: "tree",
  255. props: {
  256. label: "cname",
  257. value: "id"
  258. },
  259. span: 24,
  260. }
  261. ]
  262. },
  263. hostUrl: '',
  264. option: {}
  265. };
  266. },
  267. components: {
  268. detailsPage,
  269. corpType
  270. },
  271. activated() {
  272. console.log(1);
  273. // this.$refs.crud.refreshTable()
  274. },
  275. async created() {
  276. this.option = await this.getColumnData(this.getColumnName(207), option);
  277. this.getAllWorkDicts()
  278. this.option = option;
  279. const inSave = await this.delColumnData(this.getColumnName(207), option);
  280. if (inSave) {
  281. this.$nextTick(() => {
  282. this.$refs.crud.doLayout();
  283. });
  284. this.getAllWorkDicts()
  285. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  286. }
  287. },
  288. methods: {
  289. derivation() {
  290. window.open(
  291. `/api/blade-sales-part/corpsDesc/corpsExport?${this.website.tokenHeader
  292. }=${getToken()}`
  293. );
  294. },
  295. //导出
  296. outExport() {
  297. let config = { params: { ...this.search } }
  298. if (config.params) {
  299. for (const propName of Object.keys(config.params)) {
  300. const value = config.params[propName];
  301. if (value !== null && typeof (value) !== "undefined") {
  302. if (value instanceof Array) {
  303. for (const key of Object.keys(value)) {
  304. let params = propName + '[' + key + ']';
  305. config.params[params] = value[key]
  306. }
  307. delete config.params[propName]
  308. }
  309. }
  310. }
  311. }
  312. const routeData = this.$router.resolve({
  313. path: '/api/blade-sales-part/corpsDesc/pjCorpsExport', //跳转目标窗口的地址
  314. query: {
  315. ...config.params, //括号内是要传递给新窗口的参数
  316. identification: this.url
  317. }
  318. })
  319. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  320. },
  321. uploadBefore(file, done, loading) {
  322. done();
  323. loading = true;
  324. },
  325. uploadAfter(res, done, loading, column) {
  326. this.excelBox = false;
  327. let myError = res.toString();//转字符串
  328. myError = myError.replace("Error: ", "") // 去掉前面的" Error: "
  329. this.$message.success(myError);
  330. this.refreshChange();
  331. loading = false;
  332. done();
  333. },
  334. filterNode(value, data) {
  335. console.log(value, data)
  336. if (!value) return true;
  337. return data.label.indexOf(value) !== -1;
  338. },
  339. nodeClick(data) {
  340. this.search.corpsTypeId = data.value
  341. this.page.currentPage = 1;
  342. this.onLoad(this.page, this.search);
  343. },
  344. getAllWorkDicts() {
  345. this.getWorkDicts("client_status").then(res => {
  346. this.findObject(this.option.column, "status").dicData = res.data.data;
  347. });
  348. getCorpType({ corpType: 'KH' }).then(res => {
  349. this.treeData = res.data.data
  350. });
  351. customerList({ corpType: "KH" }).then(res => {
  352. this.findObject(this.option4.column, "parentId").dicData = res.data.data.records
  353. });
  354. this.$refs.crud.init();
  355. },
  356. searchCriteriaSwitch(type) {
  357. this.$refs.crud.getTableHeight();
  358. },
  359. cellStyle() {
  360. return "padding:0;height:40px;";
  361. },
  362. //点击搜索按钮触发
  363. searchChange(params, done) {
  364. this.page.currentPage = 1;
  365. this.onLoad(this.page, params);
  366. done();
  367. },
  368. refreshChange() {
  369. this.onLoad(this.page, this.search);
  370. },
  371. newAdd() {
  372. this.show = false;
  373. },
  374. onLoad(page, params = {}) {
  375. console.log('page',page);
  376. // this.$refs.crud.refreshTable()
  377. console.log('params',params);
  378. console.log('this.search',this.search);
  379. let data = this.deepClone(Object.assign(params, this.search));
  380. if (data.date && data.date.length > 0) {
  381. data.startTime = data.date[0]
  382. data.endTime = data.date[1]
  383. }
  384. delete data.date
  385. data.corpType = "KH"
  386. this.loading = true;
  387. getList({
  388. current: page.currentPage,
  389. size: page.pageSize,
  390. // ...page.pageSize,
  391. ...data
  392. }).then(res => {
  393. this.dataList = res.data.data.records ? res.data.data.records : [];
  394. this.page.total = res.data.data.total;
  395. }).finally(() => {
  396. // pageStatistics(data).then(res => {
  397. // this.form = res.data.data
  398. // })
  399. this.loading = false;
  400. });
  401. },
  402. addCorpType() {
  403. // this.$refs["corpType"].validate((valid, done) => {
  404. // done();
  405. // if (valid) {
  406. // addCorpType({ ...this.form4, corpType: 'KH', status: 0 })
  407. // .then(res => {
  408. // this.$message.success("保存成功");
  409. // this.getAllWorkDicts()
  410. // this.corpTypeVisible = false
  411. // })
  412. // } else {
  413. // return false;
  414. // }
  415. // });
  416. this.getAllWorkDicts()
  417. this.corpTypeVisible = false
  418. },
  419. corpTypeClosed() {
  420. // this.reload = Math.random();
  421. // this.form4 = this.$options.data().form4
  422. },
  423. editOpen(row, status) {
  424. this.showInfo = true;
  425. this.detailData = {
  426. id: row.id,
  427. status: status
  428. };
  429. this.show = false;
  430. },
  431. currentChange(val) {
  432. this.page.currentPage = val;
  433. },
  434. sizeChange(val) {
  435. this.page.currentPage = 1;
  436. this.page.pageSize = val;
  437. },
  438. rowDel(row, index, done) {
  439. this.$confirm("确定删除数据?", {
  440. confirmButtonText: "确定",
  441. cancelButtonText: "取消",
  442. type: "warning"
  443. }).then(() => {
  444. remove({ id: row.id, corpType: "KH" }).then(res => {
  445. if (res.data.code == 200) {
  446. this.$message({
  447. type: "success",
  448. message: "删除成功!"
  449. });
  450. this.onLoad(this.page, this.search);
  451. }
  452. });
  453. });
  454. },
  455. async saveColumn() {
  456. const inSave = await this.saveColumnData(
  457. this.getColumnName(207),
  458. this.option
  459. );
  460. if (inSave) {
  461. this.$nextTick(() => {
  462. this.$refs.crud.doLayout();
  463. });
  464. this.$message.success("保存成功");
  465. //关闭窗口
  466. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  467. }
  468. },
  469. async resetColumn() {
  470. this.option = option;
  471. const inSave = await this.delColumnData(this.getColumnName(207), option);
  472. if (inSave) {
  473. this.$nextTick(() => {
  474. this.$refs.crud.doLayout();
  475. });
  476. this.getAllWorkDicts()
  477. this.$message.success("重置成功");
  478. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  479. }
  480. },
  481. //返回列表
  482. goBack() {
  483. this.detailData = this.$options.data().detailData;
  484. this.show = true;
  485. this.showInfo = true;
  486. this.onLoad(this.page, this.search);
  487. },
  488. }
  489. }
  490. </script>
  491. <style lang="scss" scoped>
  492. .page-crad ::v-deep .basic-container__card {
  493. height: 94.2vh;
  494. }
  495. ::v-deep .el-form-item__error {
  496. display: none !important;
  497. }
  498. ::v-deep .el-input-group__append {
  499. padding: 0 0px !important;
  500. }
  501. .el-dialog ::v-deep .el-form-item__error {
  502. display: none !important;
  503. }
  504. .stat-td {
  505. text-align: center;
  506. position: relative;
  507. }
  508. .stat-img {
  509. width: 95%;
  510. height: 100px;
  511. }
  512. .stat-tip {
  513. position: absolute;
  514. left: 15px;
  515. top: 5px;
  516. .money {
  517. color: #fff;
  518. font-size: 28px;
  519. text-align: left;
  520. font-weight: 600;
  521. }
  522. .title {
  523. color: #fff;
  524. font-size: 14px;
  525. text-align: left;
  526. margin-top: 5px;
  527. margin-bottom: 0px;
  528. }
  529. }
  530. </style>