testclassifyset.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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. label: "项目类型",
  151. prop: "projectType",
  152. type:'select',
  153. dicData:[
  154. {
  155. label:'公路工程',
  156. value:0
  157. },
  158. {
  159. label:'水利工程',
  160. value:1
  161. }
  162. ],
  163. rules: [{
  164. required: true,
  165. message: "请选择项目类型",
  166. trigger: "blur"
  167. }]
  168. }
  169. ]
  170. },
  171. data: [],
  172. GLExcel:false,
  173. GLExcelFrom:{
  174. id: "",
  175. name: "",
  176. search: "", //搜素框舒服的值
  177. ids: "",
  178. excelId: "",
  179. initTableName: "",
  180. initTableId:""
  181. },
  182. searchVal:'',
  183. GLExcelData:[],
  184. exceldata:[],
  185. GLExcelProps: {
  186. label: "name",
  187. children: "children",
  188. disabled: "hasChildren",
  189. isLeaf: function (data) {
  190. let tag = false;
  191. if (!data.hasChildren) {
  192. tag = true;
  193. }
  194. if (data.isExistForm == 1) {
  195. tag = true;
  196. }
  197. return tag;
  198. },
  199. },
  200. testGLExcel:false,
  201. checkId:'',
  202. treeKey:Math.random,
  203. setId:'',
  204. trialTreeIds:'',//已关联的配置划分数据
  205. linkexcelId:[]//已关联的清表数据
  206. };
  207. },
  208. computed: {
  209. ...mapGetters(["permission"]),
  210. permissionList() {
  211. return {
  212. viewBtn: false,
  213. //addBtn: this.vaildData(this.permission.imageclassificationconfig_add, false),
  214. //viewBtn: this.vaildData(this.permission.imageclassificationconfig_view, false),
  215. //delBtn: this.vaildData(this.permission.imageclassificationconfig_delete, false),
  216. // editBtn: this.vaildData(this.permission.imageclassificationconfig_edit, false)
  217. };
  218. },
  219. ids() {
  220. let ids = [];
  221. this.selectionList.forEach(ele => {
  222. ids.push(ele.id);
  223. });
  224. return ids.join(",");
  225. }
  226. },
  227. watch: {
  228. searchVal(val) {
  229. if (this.exceldata) {
  230. this.$refs.tree.filter(val);
  231. }
  232. },
  233. },
  234. methods: {
  235. rowSave(row, done, loading) {
  236. add(row).then(() => {
  237. this.onLoad(this.page);
  238. this.$message({
  239. type: "success",
  240. message: "操作成功!"
  241. });
  242. done();
  243. }, error => {
  244. loading();
  245. window.console.log(error);
  246. });
  247. },
  248. rowUpdate(row, index, done, loading) {
  249. update(row).then(() => {
  250. this.onLoad(this.page);
  251. this.$message({
  252. type: "success",
  253. message: "操作成功!"
  254. });
  255. done();
  256. }, error => {
  257. loading();
  258. console.log(error);
  259. });
  260. },
  261. rowDel(row) {
  262. this.$confirm("确定将选择数据删除?", {
  263. confirmButtonText: "确定",
  264. cancelButtonText: "取消",
  265. type: "warning"
  266. })
  267. .then(() => {
  268. return remove(row.id);
  269. })
  270. .then(() => {
  271. this.onLoad(this.page);
  272. this.$message({
  273. type: "success",
  274. message: "操作成功!"
  275. });
  276. });
  277. },
  278. beforeOpen(done, type) {
  279. if (["edit", "view"].includes(type)) {
  280. getDetail(this.form.id).then(res => {
  281. this.form = res.data.data;
  282. });
  283. }
  284. done();
  285. },
  286. searchReset() {
  287. this.query = {};
  288. this.onLoad(this.page);
  289. },
  290. searchChange(params, done) {
  291. this.query = params;
  292. this.page.currentPage = 1;
  293. this.onLoad(this.page, params);
  294. done();
  295. },
  296. selectionChange(list) {
  297. this.selectionList = list;
  298. },
  299. selectionClear() {
  300. this.selectionList = [];
  301. this.$refs.crud.toggleSelection();
  302. },
  303. currentChange(currentPage){
  304. this.page.currentPage = currentPage;
  305. },
  306. sizeChange(pageSize){
  307. this.page.pageSize = pageSize;
  308. },
  309. refreshChange() {
  310. this.onLoad(this.page, this.query);
  311. },
  312. onLoad(page, params = {}) {
  313. this.loading = true;
  314. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  315. const data = res.data.data;
  316. this.page.total = data.total;
  317. this.data = data.records;
  318. this.loading = false;
  319. this.selectionClear();
  320. });
  321. },
  322. //关联清表
  323. Associationlist(row) {
  324. //关联清表点击事件
  325. if(row.excelId){
  326. this.linkexcelId=row.excelId.split(',')
  327. }
  328. this.GLExcel =true ;
  329. this.GLExcelFrom.id = row.id;
  330. this.GLExcelFrom=row
  331. this.searchVal=''
  332. this.treeKey=Math.random()
  333. this.getList({
  334. current: 1,
  335. size: 100000,
  336. parentId: 0,
  337. });
  338. },
  339. GLExcelMD() {
  340. //弹框关闭事件
  341. this.GLExcelFrom.name = "";
  342. this.GLExcelFrom.search = "";
  343. this.GLExcelFrom.id = "";
  344. this.exceldata = [];
  345. this.checkId=''
  346. this.GLExcel = false;
  347. },
  348. changetherr(val) {
  349. console.log(val,'val');
  350. //清表类型选择框change事件
  351. if (this.GLExcelFrom.name != "") {
  352. this.GLExcelFrom.search = "";
  353. this.checkId=val
  354. this.treeKey=Math.random()
  355. }
  356. },
  357. loadNode(node, resolve) {
  358. let pid = 0;
  359. let modeId=this.checkId;
  360. if (node.level != 0) {
  361. pid = node.data.id;
  362. modeId=node.data.parentId
  363. }
  364. tablazy({
  365. modeId: modeId,
  366. parentId: pid,
  367. classId:this.GLExcelFrom.id
  368. }).then((res) => {
  369. let arr = [];
  370. if (Array.isArray(res.data.data)) {
  371. arr = res.data.data;
  372. }
  373. return resolve(arr);
  374. });
  375. },
  376. filterNode222(value,data,node) {
  377. if(!value){
  378. return true;
  379. }
  380. let level = node.level;
  381. let _array = [];//这里使用数组存储 只是为了存储值。
  382. this.getReturnNode2(node,_array,value);
  383. let result = false;
  384. _array.forEach((item)=>{
  385. result = result || item;
  386. });
  387. return result;
  388. },
  389. getReturnNode2(node,_array,value){
  390. let isPass = node.data && node.data.name && node.data.name.indexOf(value) !== -1;
  391. isPass?_array.push(isPass):'';
  392. if(!isPass && node.level!=1 && node.parent){
  393. this.getReturnNode2(node.parent,_array,value);
  394. }
  395. },
  396. async getList(da) {
  397. //获取清表模板信息
  398. const { data: res } = await getListQing(da);
  399. console.log(res);
  400. if (res.code === 200 && res.msg === "操作成功") {
  401. this.GLExcelData = res.data.records;
  402. }
  403. },
  404. checkchange(data) {
  405. //节点选中回调
  406. if (this.$refs.tree.getCheckedNodes().length === 0) {
  407. this.$refs.tree.setCheckedKeys([]);
  408. } else if (this.$refs.tree.getCheckedNodes().length >= 1) {
  409. this.$refs.tree.setCheckedKeys([data.id]);
  410. }
  411. },
  412. async saveLink() {
  413. //保存按钮
  414. let checkIds=this.$refs.tree.getCheckedKeys();
  415. if (checkIds.length > 0) {
  416. const { data: res } = await relevancy({
  417. classId:this.GLExcelFrom.id,
  418. excelId:checkIds.join(',')
  419. });
  420. console.log(res);
  421. if (res.code === 200) {
  422. this.$message({
  423. type: "success",
  424. message: "关联清表成功",
  425. });
  426. this.GLExcel =false ;
  427. this.refreshChange()
  428. }
  429. } else {
  430. this.$message({
  431. type: "warning",
  432. message: "请先选择清表",
  433. });
  434. }
  435. },
  436. //配置划分
  437. configurationClick(row){
  438. this.testGLExcel=true
  439. this.setId=row.id
  440. this.trialTreeIds=row.trialTreeIds
  441. },
  442. changemodal(){
  443. this.testGLExcel=false
  444. this.refreshChange()
  445. },
  446. //数据映射配置
  447. associatedClick(row) {
  448. this.$router.push({
  449. path: '/tentative/dataMap',
  450. query: { classId: row.id }
  451. });
  452. },
  453. },
  454. };
  455. </script>
  456. <style>
  457. </style>