index.vue 9.0 KB

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