index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <el-row>
  3. <el-col :span="5">
  4. <div class="box">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree
  8. :option="treeOption"
  9. :data="treeData"
  10. @node-click="nodeClick"
  11. />
  12. </basic-container>
  13. </el-scrollbar>
  14. </div>
  15. </el-col>
  16. <el-col :span="19">
  17. <basic-container>
  18. <avue-crud
  19. :option="option"
  20. :data="dataList"
  21. ref="crud"
  22. v-model="form"
  23. :page.sync="page"
  24. @row-del="rowDel"
  25. @row-update="rowUpdate"
  26. :before-open="beforeOpen"
  27. :before-close="beforeClose"
  28. @row-save="rowSave"
  29. @search-change="searchChange"
  30. @search-reset="searchReset"
  31. @selection-change="selectionChange"
  32. @current-change="currentChange"
  33. @size-change="sizeChange"
  34. @refresh-change="refreshChange"
  35. @on-load="onLoad"
  36. @tree-load="treeLoad"
  37. >
  38. <template slot="menuLeft">
  39. <el-button
  40. type="primary"
  41. size="small"
  42. icon="el-icon-bottom"
  43. @click="excelBox = true"
  44. >导入
  45. </el-button>
  46. <el-button
  47. icon="el-icon-printer"
  48. size="small"
  49. type="primary"
  50. @click.stop="openReport()"
  51. >报 表
  52. </el-button>
  53. </template>
  54. <template slot-scope="scope" slot="menu">
  55. <el-button
  56. type="text"
  57. icon="el-icon-view"
  58. size="small"
  59. @click.stop="beforeOpenPage(scope.row, scope.index)"
  60. >查看
  61. </el-button>
  62. <el-button
  63. type="text"
  64. icon="el-icon-edit"
  65. size="small"
  66. @click.stop="editOpen(scope.row, scope.index)"
  67. >编辑
  68. </el-button>
  69. <el-button
  70. type="text"
  71. icon="el-icon-delete"
  72. size="small"
  73. @click.stop="rowDel(scope.row, scope.index)"
  74. >删除
  75. </el-button>
  76. </template>
  77. </avue-crud>
  78. <report-dialog
  79. :switchDialog="switchDialog"
  80. @onClose="onClose()"
  81. ></report-dialog>
  82. <el-dialog
  83. title="导入客户"
  84. append-to-body
  85. :visible.sync="excelBox"
  86. width="555px"
  87. v-dialog-drag
  88. >
  89. <avue-form
  90. :option="excelOption"
  91. v-model="excelForm"
  92. table-loading="excelLoading"
  93. :upload-before="uploadBefore"
  94. :upload-after="uploadAfter"
  95. >
  96. <template slot="excelTemplate">
  97. <el-button type="primary" @click="derivation">
  98. 点击下载<i class="el-icon-download el-icon--right"></i>
  99. </el-button>
  100. </template>
  101. </avue-form>
  102. <p style="text-align: center;color: #DC0505">
  103. 温馨提示 第一次导入时请先下载模板
  104. </p>
  105. </el-dialog>
  106. </basic-container>
  107. </el-col>
  108. </el-row>
  109. </template>
  110. <script>
  111. import option from "./configuration/mainList.json";
  112. import {
  113. customerList,
  114. typeSave,
  115. detail,
  116. deleteDetails,
  117. getDeptLazyTree
  118. } from "@/api/basicData/customerInformation";
  119. import { getToken } from "@/util/auth";
  120. import reportDialog from "@/components/report-dialog/main";
  121. import { companyParameter} from "@/enums/management-type";
  122. export default {
  123. name: "customerInformation",
  124. data() {
  125. return {
  126. reportQuery: {},
  127. switchDialog: false,
  128. treeDeptId: "",
  129. form: {},
  130. option: option,
  131. parentId: 0,
  132. dataList: [],
  133. treeOption: {
  134. nodeKey: "id",
  135. lazy: true,
  136. treeLoad: function(node, resolve) {
  137. const parentId = node.level === 0 ? 0 : node.data.id;
  138. getDeptLazyTree({
  139. parentId: parentId,
  140. corpType: companyParameter.code
  141. }).then(res => {
  142. resolve(
  143. res.data.data.map(item => {
  144. return {
  145. ...item,
  146. leaf: !item.hasChildren
  147. };
  148. })
  149. );
  150. });
  151. },
  152. addBtn: false,
  153. menu: false,
  154. size: "small",
  155. props: {
  156. labelText: "标题",
  157. label: "title",
  158. value: "value",
  159. children: "children"
  160. }
  161. },
  162. page: {
  163. pageSize: 10,
  164. pagerCount: 5,
  165. total: 0,
  166. pageSizes: [10, 50, 100, 200, 300]
  167. },
  168. excelBox: false,
  169. excelLoading: false,
  170. excelForm: {},
  171. excelOption: {
  172. submitBtn: false,
  173. emptyBtn: false,
  174. column: [
  175. {
  176. label: "模板下载",
  177. prop: "excelTemplate",
  178. formslot: true,
  179. span: 24
  180. },
  181. {
  182. label: "模板上传",
  183. prop: "excelFile",
  184. type: "upload",
  185. drag: true,
  186. loadText: "模板上传中,请稍等",
  187. span: 24,
  188. propsHttp: {
  189. res: "data"
  190. },
  191. tip: "请上传 .xls,.xlsx 标准格式文件",
  192. action: "/api/blade-client/corpsdesc/import-desc"
  193. }
  194. ]
  195. }
  196. };
  197. },
  198. components: {
  199. reportDialog
  200. },
  201. created() {},
  202. // watch:{
  203. // 'excelForm.isCovered'() {
  204. // if (this.excelForm.isCovered !== '') {
  205. // const column = this.findObject(this.excelOption.column, "excelFile");
  206. // column.action = `/api/blade-user/import-user?isCovered=${this.excelForm.isCovered}`;
  207. // }
  208. // }
  209. // },
  210. methods: {
  211. derivation() {
  212. window.open(
  213. `/api/blade-client/corpsdesc/export-template?${
  214. this.website.tokenHeader
  215. }=${getToken()}`
  216. );
  217. },
  218. uploadBefore(file, done, loading) {
  219. done();
  220. loading = true;
  221. },
  222. uploadAfter(res, done, loading, column) {
  223. window.console.log(column);
  224. this.excelBox = false;
  225. this.$message.success("导入成功!");
  226. this.refreshChange();
  227. loading = false;
  228. done();
  229. },
  230. nodeClick(data) {
  231. this.treeDeptId = data.id;
  232. this.page.currentPage = 1;
  233. this.onLoad(this.page);
  234. },
  235. //删除列表后面的删除按钮触发触发(row, index, done)
  236. rowDel(row, index, done) {
  237. this.$confirm("确定将选择数据删除?", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. })
  242. .then(() => {
  243. return deleteDetails(row.id);
  244. })
  245. .then(() => {
  246. this.$message({
  247. type: "success",
  248. message: "操作成功!"
  249. });
  250. this.page.currentPage = 1;
  251. this.onLoad(this.page, { parentId: 0 });
  252. });
  253. },
  254. //修改时的修改按钮点击触发
  255. rowUpdate(row, index, done, loading) {
  256. typeSave(row).then(
  257. () => {
  258. this.$message({
  259. type: "success",
  260. message: "操作成功!"
  261. });
  262. // 数据回调进行刷新
  263. done(row);
  264. },
  265. error => {
  266. window.console.log(error);
  267. loading();
  268. }
  269. );
  270. },
  271. //新增修改时保存触发
  272. rowSave(row, done, loading) {
  273. typeSave(row).then(res => {
  274. console.log(res);
  275. done();
  276. });
  277. },
  278. //查询全部
  279. initData() {
  280. customerList({ corpType: companyParameter.code }).then(res => {
  281. console.log(this.form);
  282. const column = this.findObject(this.option.column, "parentId");
  283. column.dicData = res.data.data.records;
  284. });
  285. },
  286. //新增子项触发
  287. handleAdd(row) {
  288. this.parentId = row.id;
  289. const column = this.findObject(this.option.column, "parentId");
  290. column.value = row.id;
  291. column.addDisabled = true;
  292. this.$refs.crud.rowAdd();
  293. },
  294. //查看跳转页面
  295. beforeOpenPage(row, index) {
  296. this.$router.push({
  297. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  298. query: { id: JSON.stringify(row.id) }
  299. });
  300. },
  301. //新增跳转页面
  302. beforeOpen(row, index) {
  303. this.$router.push({
  304. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  305. query: { id: JSON.stringify(row.id), treeDeptId: this.treeDeptId }
  306. });
  307. },
  308. editOpen(row, index) {
  309. this.$router.push({
  310. path: "/basicData/customerManagement/companyMaterial/detailsPageEdit",
  311. query: { id: JSON.stringify(row.id) }
  312. });
  313. },
  314. //点击新增时触发
  315. beforeClose(done) {
  316. this.parentId = "";
  317. const column = this.findObject(this.option.column, "parentId");
  318. column.value = "";
  319. column.addDisabled = false;
  320. done();
  321. },
  322. //点击搜索按钮触发
  323. searchChange(params, done) {
  324. console.log(params);
  325. this.page.currentPage = 1;
  326. this.onLoad(this.page, params);
  327. done();
  328. },
  329. //搜索重置按钮触发
  330. searchReset() {
  331. this.treeDeptId = "";
  332. this.onLoad(this.page);
  333. },
  334. selectionChange() {
  335. console.log("1");
  336. },
  337. currentChange() {
  338. console.log("1");
  339. },
  340. sizeChange() {
  341. console.log("1");
  342. },
  343. refreshChange() {
  344. this.onLoad(this.page);
  345. },
  346. onLoad(page, params = { parentId: 0 }) {
  347. let queryParams = Object.assign({}, params, {
  348. size: page.pageSize,
  349. current: page.currentPage,
  350. corpsTypeId: this.treeDeptId,
  351. corpType: companyParameter.code
  352. });
  353. customerList(queryParams).then(res => {
  354. this.dataList = res.data.data.records;
  355. this.page.total = res.data.data.total;
  356. });
  357. },
  358. //树桩列点击展开触发
  359. treeLoad(tree, treeNode, resolve) {
  360. const parentId = tree.id;
  361. customerList({ parentId: parentId, corpType: companyParameter.code }).then(
  362. res => {
  363. resolve(res.data.data.records);
  364. }
  365. );
  366. },
  367. openReport() {
  368. this.switchDialog = !this.switchDialog;
  369. },
  370. onClose(val) {
  371. this.switchDialog = val;
  372. }
  373. }
  374. };
  375. </script>
  376. <style scoped></style>