index.vue 9.5 KB

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