relation.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <el-dialog
  3. title="关联清表"
  4. :visible.sync="GLExcel"
  5. append-to-body
  6. destroy-on-close
  7. @close="GLExcelMD"
  8. width="800px"
  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. :initTableId="editElementQuery.initTableId"
  75. :pid="editElementQuery.pid"
  76. :wbsid="editElementQuery.wbsid"
  77. :nodeid="editElementQuery.nodeid"
  78. @hideDialog="editElementVisible = false"
  79. v-if="editElementVisible"
  80. :globaltype='1'
  81. :elementType="true"
  82. ></EditElement>
  83. </el-dialog>
  84. </el-dialog>
  85. </template>
  86. <script>
  87. import {getList,tabLazytreeAll,saveLinkTab, getExcelHtml,} from "@/api/exctab/excelmodel";
  88. import EditElement from "@/views/manager/projectinfo/editElement/editElement.vue";
  89. import {findNodeTableByCondition as selectByNodeTable} from "@/api/manager/wbsprivate";
  90. export default {
  91. props:{
  92. GLExcelFrom:Object,
  93. onLoad1:Function,
  94. refreshTree:Function
  95. },
  96. components:{EditElement},
  97. data(){
  98. return{
  99. GLExcel:false,
  100. // GLExcelFrom: {
  101. // id: "",
  102. // name: "",
  103. // search: "", //搜素框舒服的值
  104. // ids: "",
  105. // excelId: "",
  106. // initTableName: "",
  107. // },
  108. editElementQuery: {
  109. pkeyId: "",
  110. excelId: "",
  111. id: "",
  112. initTableName: "",
  113. pid: "",
  114. wbsid: "",
  115. nodeid: "",
  116. },
  117. exceldata: [], //清表模板
  118. GLExcelData: [], //
  119. GLExcelLoading: false,
  120. editElementVisible: false, //编辑元素弹框
  121. GLExcelProps: {
  122. label: "name",
  123. children: "children",
  124. disabled: "hasChildren",
  125. isLeaf: function (data) {
  126. let tag = false;
  127. if (!data.hasChildren) {
  128. tag = true;
  129. }
  130. if (data.isExistForm == 1) {
  131. tag = true;
  132. }
  133. return tag;
  134. },
  135. },
  136. }
  137. },
  138. watch: {
  139. "GLExcelFrom.search"(val) {
  140. console.log(val);
  141. if (this.exceldata) {
  142. this.$refs.tree.filter(val);
  143. }
  144. },
  145. },
  146. methods:{
  147. show(){
  148. this.GLExcel=true;
  149. console.log(this.GLExcel,'GLExcel');
  150. console.log(this.GLExcelFrom,'GLExcelFrom');
  151. this.getList({
  152. current: 1,
  153. size: 100000,
  154. parentId: 0,
  155. });
  156. setTimeout(() => {
  157. this.$refs.tree.setCheckedKeys([this.GLExcelFrom.excelId]);
  158. }, 2000);
  159. },
  160. GLExcelMD() {
  161. //弹框关闭事件
  162. this.GLExcelFrom.name = "";
  163. this.GLExcelFrom.search = "";
  164. this.GLExcelFrom.id = "";
  165. this.exceldata = [];
  166. this.$refs.tree.setCheckedKeys([]);
  167. this.GLExcel = false;
  168. },
  169. async tabLazytreeAll() {
  170. //清表树信息
  171. this.GLExcelLoading = true;
  172. const { data: res } = await tabLazytreeAll({
  173. modeId: this.GLExcelFrom.name,
  174. name: this.GLExcelFrom.search,
  175. });
  176. this.GLExcelLoading = false;
  177. console.log(res);
  178. if (res.code === 200 && res.msg === "操作成功") {
  179. this.exceldata = res.data;
  180. }
  181. },
  182. changetherr() {
  183. //清表类型选择框change事件
  184. if (this.GLExcelFrom.name != "") {
  185. this.GLExcelFrom.search = "";
  186. this.tabLazytreeAll();
  187. }
  188. },
  189. //#region 关联清表
  190. async getList(da) {
  191. //获取清表模板信息
  192. const { data: res } = await getList(da);
  193. console.log(res);
  194. if (res.code === 200 && res.msg === "操作成功") {
  195. this.GLExcelData = res.data.records;
  196. }
  197. },
  198. filterNode222(value, data) {
  199. if (!value) return true;
  200. return data.name.indexOf(value) !== -1;
  201. },
  202. checkchange(data) {
  203. //节点选中回调
  204. if (this.$refs.tree.getCheckedNodes().length === 0) {
  205. this.$refs.tree.setCheckedKeys([]);
  206. } else if (this.$refs.tree.getCheckedNodes().length >= 1) {
  207. this.$refs.tree.setCheckedKeys([data.id]);
  208. }
  209. },
  210. async getExcelHtml2(pkeyId) {
  211. const { data: res } = await getExcelHtml({ pkeyId });
  212. console.log(res);
  213. if (res.code === 200) {
  214. localStorage.setItem("editElement", res.data);
  215. }
  216. },
  217. //#region 编辑元素
  218. async rightClick(pkeyId, excelId, id, initTableName,initTableId,nodeid) {
  219. await this.getExcelHtml2(pkeyId);
  220. this.editElementQuery.pkeyId = pkeyId;
  221. this.editElementQuery.excelId = excelId;
  222. this.editElementQuery.id = id;
  223. this.editElementQuery.initTableName = initTableName;
  224. this.editElementQuery.pid = this.$route.query.pid;
  225. this.editElementQuery.wbsid = this.$route.query.wbsid;
  226. this.editElementQuery.initTableId = initTableId;
  227. this.editElementQuery.nodeid =nodeid;
  228. this.editElementVisible = true;
  229. },
  230. updateNodeTable() {
  231. // selectByNodeTable(this.curTreeData.id, this.projectid, this.id).then(
  232. // (res) => {
  233. // if (res.data.data.length) {
  234. // this.formData = res.data.data;
  235. // } else {
  236. // this.formData = [];
  237. // }
  238. // }
  239. // );
  240. },
  241. async saveLinkTab() {
  242. //保存按钮
  243. let checkNodes = this.$refs.tree.getCheckedNodes();
  244. if (checkNodes.length > 0) {
  245. let node = checkNodes[checkNodes.length - 1];
  246. if (node.fileType != 3) {
  247. this.$message({
  248. type: "warning",
  249. message: "请先上传Excel表",
  250. });
  251. return;
  252. }
  253. console.log(node.id,'node.id');
  254. console.log(this.GLExcelFrom.id,'this.GLExcelFrom.id');
  255. const { data: res } = await saveLinkTab({
  256. exceTabId: node.id,
  257. tabId: this.GLExcelFrom.id
  258. });
  259. console.log(res);
  260. if (res.code === 200) {
  261. this.$message({
  262. type: "success",
  263. message: "关联清表成功",
  264. });
  265. // selectByNodeTable刷新表单列表
  266. this.onLoad1();
  267. this.refreshTree()
  268. this.GLExcel = false;
  269. this.rightClick(
  270. this.GLExcelFrom.id,
  271. this.GLExcelFrom.excelId,
  272. this.GLExcelFrom.ids,
  273. this.GLExcelFrom.initTableName,
  274. this.GLExcelFrom.initTableId,
  275. this.GLExcelFrom.nodeid
  276. );
  277. }
  278. } else {
  279. this.$message({
  280. type: "warning",
  281. message: "请先设置清表",
  282. });
  283. }
  284. },
  285. }
  286. }
  287. </script>
  288. <style scoped lang="scss">
  289. .excelBox {
  290. /deep/.el-dialog__body {
  291. padding: 20px;
  292. }
  293. }
  294. </style>