index.vue 9.2 KB

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