testclassifyset.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @selection-change="selectionChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad">
  19. <template slot-scope="{type,size,row}" slot="menu">
  20. <el-button icon="el-icon-setting" :size="size" :type="type" @click="configurationClick(row)">配置划分</el-button>
  21. <el-button icon="el-icon-setting" :size="size" :type="type" @click="Associationlist(row)">关联清表</el-button>
  22. <el-button icon="el-icon-setting" :size="size" :type="type" @click="associatedClick(row)">数据映射配置</el-button>
  23. </template>
  24. </avue-crud>
  25. <!-- 关联清表 -->
  26. <el-dialog
  27. title="关联下载模板表"
  28. class="excelBox"
  29. :visible.sync="GLExcel"
  30. width="500px"
  31. modal-append-to-body
  32. append-to-body
  33. @close="GLExcelMD"
  34. >
  35. <div class="mg-b-10">
  36. <el-alert
  37. :closable="false"
  38. title="选择需要关联的清表 注意:每次只能单选操作"
  39. type="warning">
  40. </el-alert>
  41. </div>
  42. <div>
  43. <el-select
  44. style="width: 100%"
  45. v-model="GLExcelFrom.name"
  46. placeholder="请选择"
  47. @change="changetherr"
  48. >
  49. <el-option
  50. v-for="(item, key) in GLExcelData"
  51. :key="key"
  52. :label="item.name"
  53. :value="item.id"
  54. >
  55. </el-option>
  56. </el-select>
  57. <el-scrollbar style="margin-top: 20px; height: 50vh">
  58. <el-input
  59. style="width: 100%"
  60. v-model.trim="searchVal"
  61. placeholder="请输入需要选择的内容"
  62. ></el-input>
  63. <el-tree
  64. v-if="checkId"
  65. :key="treeKey"
  66. lazy
  67. :filter-node-method="filterNode222"
  68. ref="tree"
  69. class="filter-tree"
  70. style="margin-top: 10px"
  71. :props="GLExcelProps"
  72. :load="loadNode"
  73. node-key="id"
  74. accordion
  75. show-checkbox
  76. @check="checkchange"
  77. v-loading="GLExcelLoading"
  78. :default-checked-keys="linkexcelId"
  79. >
  80. </el-tree>
  81. </el-scrollbar>
  82. </div>
  83. <span
  84. slot="footer"
  85. class="dialog-footer"
  86. style="display: flex; justify-content: center; align-items: center"
  87. >
  88. <el-button @click="GLExcelMD()">取 消</el-button>
  89. <el-button
  90. style="margin-left: 30px"
  91. type="primary"
  92. v-throttle="2000"
  93. @click="saveLink()"
  94. >确 定</el-button
  95. >
  96. </span>
  97. </el-dialog>
  98. <!-- 配置划分数据 -->
  99. <configDivision :testGLExcel="testGLExcel" :setId="setId" @changemodal="changemodal" :trialTreeIds="trialTreeIds"></configDivision>
  100. </basic-container>
  101. </template>
  102. <script>
  103. import {getList, getDetail, add, update, remove} from "@/api/tentative/testcollect";
  104. import {mapGetters} from "vuex";
  105. import {
  106. getList as getListQing,
  107. } from "@/api/exctab/excelmodel";
  108. import {relevancy,tablazy} from "@/api/tentative/testcollect";
  109. import configDivision from "./components/configDivision.vue";
  110. export default {
  111. components:{
  112. configDivision
  113. },
  114. data() {
  115. return {
  116. form: {},
  117. query: {},
  118. loading: true,
  119. page: {
  120. pageSize: 20,
  121. currentPage: 1,
  122. total: 0
  123. },
  124. search:{},
  125. selectionList: [],
  126. option: {
  127. menuWidth:440,
  128. height:'auto',
  129. calcHeight: 30,
  130. tip: false,
  131. searchShow: false,
  132. searchMenuSpan: 0,
  133. border: true,
  134. index: true,
  135. viewBtn: true,
  136. selection: false,
  137. dialogClickModal: false,
  138. labelWidth:150,
  139. column: [
  140. {
  141. label: "分类名称",
  142. prop: "className",
  143. rules: [{
  144. required: true,
  145. message: "请输入分类名称",
  146. trigger: "blur"
  147. }]
  148. }
  149. ]
  150. },
  151. data: [],
  152. GLExcel:false,
  153. GLExcelFrom:{
  154. id: "",
  155. name: "",
  156. search: "", //搜素框舒服的值
  157. ids: "",
  158. excelId: "",
  159. initTableName: "",
  160. initTableId:""
  161. },
  162. searchVal:'',
  163. GLExcelData:[],
  164. exceldata:[],
  165. GLExcelProps: {
  166. label: "name",
  167. children: "children",
  168. disabled: "hasChildren",
  169. isLeaf: function (data) {
  170. let tag = false;
  171. if (!data.hasChildren) {
  172. tag = true;
  173. }
  174. if (data.isExistForm == 1) {
  175. tag = true;
  176. }
  177. return tag;
  178. },
  179. },
  180. testGLExcel:false,
  181. checkId:'',
  182. treeKey:Math.random,
  183. setId:'',
  184. trialTreeIds:'',//已关联的配置划分数据
  185. linkexcelId:[]//已关联的清表数据
  186. };
  187. },
  188. computed: {
  189. ...mapGetters(["permission"]),
  190. permissionList() {
  191. return {
  192. viewBtn: false,
  193. //addBtn: this.vaildData(this.permission.imageclassificationconfig_add, false),
  194. //viewBtn: this.vaildData(this.permission.imageclassificationconfig_view, false),
  195. //delBtn: this.vaildData(this.permission.imageclassificationconfig_delete, false),
  196. // editBtn: this.vaildData(this.permission.imageclassificationconfig_edit, false)
  197. };
  198. },
  199. ids() {
  200. let ids = [];
  201. this.selectionList.forEach(ele => {
  202. ids.push(ele.id);
  203. });
  204. return ids.join(",");
  205. }
  206. },
  207. watch: {
  208. searchVal(val) {
  209. if (this.exceldata) {
  210. this.$refs.tree.filter(val);
  211. }
  212. },
  213. },
  214. methods: {
  215. rowSave(row, done, loading) {
  216. add(row).then(() => {
  217. this.onLoad(this.page);
  218. this.$message({
  219. type: "success",
  220. message: "操作成功!"
  221. });
  222. done();
  223. }, error => {
  224. loading();
  225. window.console.log(error);
  226. });
  227. },
  228. rowUpdate(row, index, done, loading) {
  229. update(row).then(() => {
  230. this.onLoad(this.page);
  231. this.$message({
  232. type: "success",
  233. message: "操作成功!"
  234. });
  235. done();
  236. }, error => {
  237. loading();
  238. console.log(error);
  239. });
  240. },
  241. rowDel(row) {
  242. this.$confirm("确定将选择数据删除?", {
  243. confirmButtonText: "确定",
  244. cancelButtonText: "取消",
  245. type: "warning"
  246. })
  247. .then(() => {
  248. return remove(row.id);
  249. })
  250. .then(() => {
  251. this.onLoad(this.page);
  252. this.$message({
  253. type: "success",
  254. message: "操作成功!"
  255. });
  256. });
  257. },
  258. beforeOpen(done, type) {
  259. if (["edit", "view"].includes(type)) {
  260. getDetail(this.form.id).then(res => {
  261. this.form = res.data.data;
  262. });
  263. }
  264. done();
  265. },
  266. searchReset() {
  267. this.query = {};
  268. this.onLoad(this.page);
  269. },
  270. searchChange(params, done) {
  271. this.query = params;
  272. this.page.currentPage = 1;
  273. this.onLoad(this.page, params);
  274. done();
  275. },
  276. selectionChange(list) {
  277. this.selectionList = list;
  278. },
  279. selectionClear() {
  280. this.selectionList = [];
  281. this.$refs.crud.toggleSelection();
  282. },
  283. currentChange(currentPage){
  284. this.page.currentPage = currentPage;
  285. },
  286. sizeChange(pageSize){
  287. this.page.pageSize = pageSize;
  288. },
  289. refreshChange() {
  290. this.onLoad(this.page, this.query);
  291. },
  292. onLoad(page, params = {}) {
  293. this.loading = true;
  294. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  295. const data = res.data.data;
  296. this.page.total = data.total;
  297. this.data = data.records;
  298. this.loading = false;
  299. this.selectionClear();
  300. });
  301. },
  302. //关联清表
  303. Associationlist(row) {
  304. //关联清表点击事件
  305. if(row.excelId!==-1){
  306. this.linkexcelId=row.excelId.split(',')
  307. }
  308. this.GLExcelFrom.id = row.id;
  309. this.GLExcelFrom=row
  310. this.searchVal=''
  311. this.GLExcel =true ;
  312. this.treeKey=Math.random()
  313. this.getList({
  314. current: 1,
  315. size: 100000,
  316. parentId: 0,
  317. });
  318. },
  319. GLExcelMD() {
  320. //弹框关闭事件
  321. this.GLExcelFrom.name = "";
  322. this.GLExcelFrom.search = "";
  323. this.GLExcelFrom.id = "";
  324. this.exceldata = [];
  325. this.checkId=''
  326. this.GLExcel = false;
  327. },
  328. changetherr(val) {
  329. console.log(val,'val');
  330. //清表类型选择框change事件
  331. if (this.GLExcelFrom.name != "") {
  332. this.GLExcelFrom.search = "";
  333. this.checkId=val
  334. this.treeKey=Math.random()
  335. }
  336. },
  337. loadNode(node, resolve) {
  338. let pid = 0;
  339. let modeId=this.checkId;
  340. if (node.level != 0) {
  341. pid = node.data.id;
  342. modeId=node.data.parentId
  343. }
  344. tablazy({
  345. modeId: modeId,
  346. parentId: pid,
  347. classId:this.GLExcelFrom.id
  348. }).then((res) => {
  349. let arr = [];
  350. if (Array.isArray(res.data.data)) {
  351. arr = res.data.data;
  352. }
  353. return resolve(arr);
  354. });
  355. },
  356. filterNode222(value,data,node) {
  357. if(!value){
  358. return true;
  359. }
  360. let level = node.level;
  361. let _array = [];//这里使用数组存储 只是为了存储值。
  362. this.getReturnNode2(node,_array,value);
  363. let result = false;
  364. _array.forEach((item)=>{
  365. result = result || item;
  366. });
  367. return result;
  368. },
  369. getReturnNode2(node,_array,value){
  370. let isPass = node.data && node.data.name && node.data.name.indexOf(value) !== -1;
  371. isPass?_array.push(isPass):'';
  372. if(!isPass && node.level!=1 && node.parent){
  373. this.getReturnNode2(node.parent,_array,value);
  374. }
  375. },
  376. async getList(da) {
  377. //获取清表模板信息
  378. const { data: res } = await getListQing(da);
  379. console.log(res);
  380. if (res.code === 200 && res.msg === "操作成功") {
  381. this.GLExcelData = res.data.records;
  382. }
  383. },
  384. checkchange(data) {
  385. //节点选中回调
  386. if (this.$refs.tree.getCheckedNodes().length === 0) {
  387. this.$refs.tree.setCheckedKeys([]);
  388. } else if (this.$refs.tree.getCheckedNodes().length >= 1) {
  389. this.$refs.tree.setCheckedKeys([data.id]);
  390. }
  391. },
  392. async saveLink() {
  393. //保存按钮
  394. let checkIds=this.$refs.tree.getCheckedKeys();
  395. if (checkIds.length > 0) {
  396. const { data: res } = await relevancy({
  397. classId:this.GLExcelFrom.id,
  398. excelId:checkIds.join(',')
  399. });
  400. console.log(res);
  401. if (res.code === 200) {
  402. this.$message({
  403. type: "success",
  404. message: "关联清表成功",
  405. });
  406. this.GLExcel =false ;
  407. this.refreshChange()
  408. }
  409. } else {
  410. this.$message({
  411. type: "warning",
  412. message: "请先选择清表",
  413. });
  414. }
  415. },
  416. //配置划分
  417. configurationClick(row){
  418. this.testGLExcel=true
  419. this.setId=row.id
  420. this.trialTreeIds=row.trialTreeIds
  421. },
  422. changemodal(){
  423. this.testGLExcel=false
  424. this.refreshChange()
  425. },
  426. //数据映射配置
  427. associatedClick(row) {
  428. this.$router.push({
  429. path: '/tentative/dataMap',
  430. query: { classId: row.id }
  431. });
  432. },
  433. },
  434. };
  435. </script>
  436. <style>
  437. </style>