relation.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <el-dialog
  3. title="关联清表"
  4. :visible.sync="GLExcel"
  5. append-to-body
  6. destroy-on-close
  7. @close="GLExcelMD"
  8. width="70%"
  9. >
  10. <div>
  11. <el-select
  12. style="width: 400px"
  13. v-model="GLExcelFrom.name"
  14. placeholder="请选择"
  15. @change="changetherr()"
  16. >
  17. <el-option
  18. v-for="(item, key) in GLExcelData"
  19. :key="key"
  20. :label="item.name"
  21. :value="item.id"
  22. >
  23. </el-option>
  24. </el-select>
  25. <el-scrollbar style="margin-top: 20px; height: 50vh">
  26. <el-input
  27. style="width: 400px"
  28. v-model.trim="GLExcelFrom.search"
  29. placeholder="请输入需要选择的内容"
  30. ></el-input>
  31. <el-tree
  32. :filter-node-method="filterNode222"
  33. ref="tree"
  34. class="filter-tree"
  35. style="margin-top: 10px"
  36. :props="GLExcelProps"
  37. :data="exceldata"
  38. node-key="id"
  39. accordion
  40. show-checkbox
  41. @check="checkchange"
  42. v-loading="GLExcelLoading"
  43. >
  44. </el-tree>
  45. </el-scrollbar>
  46. </div>
  47. <span
  48. slot="footer"
  49. class="dialog-footer"
  50. style="display: flex; justify-content: center; align-items: center"
  51. >
  52. <el-button @click="GLExcelMD()">取 消</el-button>
  53. <el-button
  54. style="margin-left: 30px"
  55. type="primary"
  56. v-throttle="2000"
  57. @click="saveLinkTab()"
  58. >确 定</el-button
  59. >
  60. </span>
  61. <!-- 编辑元素 -->
  62. <el-dialog
  63. title=" "
  64. :visible.sync="editElementVisible"
  65. fullscreen
  66. append-to-body
  67. class="full-dialog"
  68. >
  69. <EditElement
  70. :pkeyId="editElementQuery.pkeyId"
  71. :excelId="editElementQuery.excelId"
  72. :id="editElementQuery.id"
  73. :initTableName="editElementQuery.initTableName"
  74. :pid="editElementQuery.pid"
  75. :wbsid="editElementQuery.wbsid"
  76. :nodeid="editElementQuery.nodeid"
  77. @hideDialog="editElementVisible = false"
  78. v-if="editElementVisible"
  79. ></EditElement>
  80. </el-dialog>
  81. </el-dialog>
  82. </template>
  83. <script>
  84. import {getList,tabLazytreeAll,saveLinkTab, getExcelHtml,} from "@/api/exctab/excelmodel";
  85. import EditElement from "@/views/manager/projectinfo/editElement/editElement.vue";
  86. import {findNodeTableByCondition as selectByNodeTable} from "@/api/manager/wbsprivate";
  87. export default {
  88. props:{
  89. GLExcelFrom:Object
  90. },
  91. components:{EditElement},
  92. data(){
  93. return{
  94. GLExcel:false,
  95. // GLExcelFrom: {
  96. // id: "",
  97. // name: "",
  98. // search: "", //搜素框舒服的值
  99. // ids: "",
  100. // excelId: "",
  101. // initTableName: "",
  102. // },
  103. editElementQuery: {
  104. pkeyId: "",
  105. excelId: "",
  106. id: "",
  107. initTableName: "",
  108. pid: "",
  109. wbsid: "",
  110. nodeid: "",
  111. },
  112. exceldata: [], //清表模板
  113. GLExcelData: [], //
  114. GLExcelLoading: false,
  115. editElementVisible: false, //编辑元素弹框
  116. GLExcelProps: {
  117. label: "name",
  118. children: "children",
  119. disabled: "hasChildren",
  120. isLeaf: function (data) {
  121. let tag = false;
  122. if (!data.hasChildren) {
  123. tag = true;
  124. }
  125. if (data.isExistForm == 1) {
  126. tag = true;
  127. }
  128. return tag;
  129. },
  130. },
  131. }
  132. },
  133. watch: {
  134. "GLExcelFrom.search"(val) {
  135. console.log(val);
  136. if (this.exceldata) {
  137. this.$refs.tree.filter(val);
  138. }
  139. },
  140. },
  141. methods:{
  142. show(){
  143. this.GLExcel=true;
  144. console.log(this.GLExcel,'GLExcel');
  145. console.log(this.GLExcelFrom,'GLExcelFrom');
  146. this.getList({
  147. current: 1,
  148. size: 100000,
  149. parentId: 0,
  150. });
  151. // setTimeout(() => {
  152. // console.log(11111111);
  153. // // this.$refs.tree.setCheckedKeys([this.GLExcelFrom.excelId]);
  154. // }, 2000);
  155. },
  156. GLExcelMD() {
  157. //弹框关闭事件
  158. this.GLExcelFrom.name = "";
  159. this.GLExcelFrom.search = "";
  160. this.GLExcelFrom.id = "";
  161. this.exceldata = [];
  162. this.$refs.tree.setCheckedKeys([]);
  163. this.GLExcel = false;
  164. },
  165. async tabLazytreeAll() {
  166. //清表树信息
  167. this.GLExcelLoading = true;
  168. const { data: res } = await tabLazytreeAll({
  169. modeId: this.GLExcelFrom.name,
  170. name: this.GLExcelFrom.search,
  171. });
  172. this.GLExcelLoading = false;
  173. console.log(res);
  174. if (res.code === 200 && res.msg === "操作成功") {
  175. this.exceldata = res.data;
  176. }
  177. },
  178. changetherr() {
  179. //清表类型选择框change事件
  180. if (this.GLExcelFrom.name != "") {
  181. this.GLExcelFrom.search = "";
  182. this.tabLazytreeAll();
  183. }
  184. },
  185. //#region 关联清表
  186. async getList(da) {
  187. //获取清表模板信息
  188. const { data: res } = await getList(da);
  189. console.log(res);
  190. if (res.code === 200 && res.msg === "操作成功") {
  191. this.GLExcelData = res.data.records;
  192. }
  193. },
  194. filterNode222(value, data) {
  195. if (!value) return true;
  196. return data.name.indexOf(value) !== -1;
  197. },
  198. checkchange(data) {
  199. //节点选中回调
  200. if (this.$refs.tree.getCheckedNodes().length === 0) {
  201. this.$refs.tree.setCheckedKeys([]);
  202. } else if (this.$refs.tree.getCheckedNodes().length >= 1) {
  203. this.$refs.tree.setCheckedKeys([data.id]);
  204. }
  205. },
  206. async getExcelHtml2(pkeyId) {
  207. const { data: res } = await getExcelHtml({ pkeyId });
  208. console.log(res);
  209. if (res.code === 200) {
  210. localStorage.setItem("editElement", res.data);
  211. }
  212. },
  213. //#region 编辑元素
  214. async rightClick(pkeyId, excelId, id, initTableName) {
  215. await this.getExcelHtml2(pkeyId);
  216. this.editElementQuery.pkeyId = pkeyId;
  217. this.editElementQuery.excelId = excelId;
  218. this.editElementQuery.id = id;
  219. this.editElementQuery.initTableName = initTableName;
  220. this.editElementQuery.pid = this.$route.query.pid;
  221. this.editElementQuery.wbsid = this.$route.query.wbsid;
  222. // this.editElementQuery.nodeid = this.curTreeData.id;
  223. this.editElementVisible = true;
  224. },
  225. updateNodeTable() {
  226. // selectByNodeTable(this.curTreeData.id, this.projectid, this.id).then(
  227. // (res) => {
  228. // if (res.data.data.length) {
  229. // this.formData = res.data.data;
  230. // } else {
  231. // this.formData = [];
  232. // }
  233. // }
  234. // );
  235. },
  236. async saveLinkTab() {
  237. //保存按钮
  238. let checkNodes = this.$refs.tree.getCheckedNodes();
  239. if (checkNodes.length > 0) {
  240. let node = checkNodes[checkNodes.length - 1];
  241. if (node.fileType != 3) {
  242. this.$message({
  243. type: "warning",
  244. message: "请先上传Excel表",
  245. });
  246. return;
  247. }
  248. console.log(node.id,'node.id');
  249. console.log(this.GLExcelFrom.id,'this.GLExcelFrom.id');
  250. const { data: res } = await saveLinkTab({
  251. exceTabId: node.id,
  252. tabId: this.GLExcelFrom.id,
  253. });
  254. console.log(res);
  255. if (res.code === 200) {
  256. this.$message({
  257. type: "success",
  258. message: "关联清表成功",
  259. });
  260. // selectByNodeTable刷新表单列表
  261. // this.updateNodeTable();
  262. this.GLExcel = false;
  263. this.rightClick(
  264. this.GLExcelFrom.id,
  265. this.GLExcelFrom.excelId,
  266. this.GLExcelFrom.ids,
  267. this.GLExcelFrom.initTableName
  268. );
  269. }
  270. } else {
  271. this.$message({
  272. type: "warning",
  273. message: "请先设置清表",
  274. });
  275. }
  276. },
  277. }
  278. }
  279. </script>
  280. <style scoped lang="scss">
  281. .excelBox {
  282. /deep/.el-dialog__body {
  283. padding: 20px;
  284. }
  285. }
  286. </style>