8
0

rightConfig.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <div style="height: 100%">
  3. <hc-tab-card :tabs="tabsData" :tab-key="tabsKey" @change="tabsChange">
  4. <div v-if="tabsKey === '1'" style="height: 100%">
  5. <el-row style="margin-bottom: 15px">
  6. <el-button type="primary" plain @click="setClick(1)"
  7. >设置为最高并卷层级</el-button
  8. >
  9. <el-button type="primary" plain @click="setClick(2)"
  10. >设置为分类卷并卷</el-button
  11. >
  12. <el-button type="primary" plain @click="setClick(3)"
  13. >设置为独立组卷</el-button
  14. >
  15. </el-row>
  16. <div style="height: 100%">
  17. <hc-card>
  18. <div style="height: 100%">
  19. <hc-card>
  20. <el-select
  21. v-model="publictreeValue"
  22. clearable
  23. placeholder="请选择公有质检化分树"
  24. @change="treeIdChange"
  25. class="w-80"
  26. >
  27. <el-option
  28. v-for="item in publictreeOptions"
  29. :key="item.id"
  30. :label="item.wbsName"
  31. :value="item.id"
  32. >
  33. </el-option>
  34. </el-select>
  35. <el-select
  36. v-model="testtreeValue"
  37. clearable
  38. placeholder="请选择试验化分树"
  39. @change="testTreeIdChange"
  40. class="w-80 ml-2"
  41. >
  42. <el-option
  43. v-for="item in testtreeOptions"
  44. :key="item.id"
  45. :label="item.wbsName"
  46. :value="item.id"
  47. >
  48. </el-option>
  49. </el-select>
  50. <div class="hc-tab-scroll-class-second mt-2">
  51. <el-scrollbar v-loading="treeLoading">
  52. <hc-data-tree
  53. ref="secondTreeRef"
  54. is-load-menu
  55. :h-props="secondTreeProps"
  56. tree-key="id"
  57. :datas="secondTreeData"
  58. show-checkbox
  59. check-strictly
  60. @load-menu="secondTreeMenu"
  61. @menu-tap="secondTreeMenuClick"
  62. >
  63. <template #name="{ data }">
  64. <template
  65. v-if="
  66. Number(
  67. data.archiveAutoGroupSelect
  68. ) === 1
  69. "
  70. >
  71. <div
  72. v-if="
  73. Number(
  74. data.archiveAutoType
  75. ) === 1
  76. "
  77. class="config_type"
  78. >
  79. </div>
  80. <div
  81. v-if="
  82. Number(
  83. data.archiveAutoType
  84. ) === 2
  85. "
  86. class="config_type"
  87. >
  88. </div>
  89. <div
  90. v-if="
  91. Number(
  92. data.archiveAutoType
  93. ) === 3
  94. "
  95. class="config_type"
  96. >
  97. </div>
  98. </template>
  99. <span
  100. class="text-16px font-400"
  101. >{{ data.title }}</span
  102. >
  103. </template>
  104. </hc-data-tree>
  105. </el-scrollbar>
  106. </div>
  107. </hc-card>
  108. </div>
  109. </hc-card>
  110. </div>
  111. </div>
  112. <div v-if="tabsKey === '2'">
  113. <entryConfig :rightData="rightData"></entryConfig>
  114. </div>
  115. </hc-tab-card>
  116. <!-- 设置最高层级 -->
  117. <hc-dialog
  118. :title="titleName"
  119. v-model="highVisible"
  120. @save="setRecordsHandle"
  121. @close="highVisible = false"
  122. >
  123. <el-checkbox-group v-model="checkList" class="wraplabel">
  124. <div v-for="node in nodesList" :key="node.id">
  125. <el-checkbox
  126. :label="node.pathName"
  127. :value="node.id"
  128. style="margin-bottom: 10px"
  129. ></el-checkbox>
  130. </div>
  131. </el-checkbox-group>
  132. </hc-dialog>
  133. <!-- 查看配置 -->
  134. <hc-dialog v-model="configVisible" title="查看配置">
  135. <div v-if="configInfo && configInfo.type">
  136. <div class="mb-2">
  137. <span>配置类别:</span>
  138. <span v-if="configInfo.type == 1">最高并卷层级</span>
  139. <span v-if="configInfo.type == 2">分类并卷</span>
  140. <span v-if="configInfo.type == 3">独立组卷</span>
  141. </div>
  142. <template v-if="configInfo.type !== 2">
  143. <div class="config-allname">
  144. {{ configInfo.data.allName }}
  145. </div>
  146. </template>
  147. <template v-else>
  148. <hc-data-tree
  149. :datas="configInfo.data"
  150. :h-props="{ label: 'nodeName' }"
  151. show-checkbox
  152. :check-strictly="true"
  153. :default-checked-keys="checkedKeys"
  154. :default-expanded-keys="checkedKeys"
  155. tree-key="id"
  156. ref="configtree"
  157. @check="configCheckChange"
  158. ></hc-data-tree>
  159. </template>
  160. </div>
  161. <div style="text-align: center; font-size: 22px" v-else>
  162. 该节点尚未配置
  163. </div>
  164. <template #footer>
  165. <el-button @click="configVisible = false">取消查看</el-button>
  166. <el-button
  167. v-if="configInfo && configInfo.type == 2"
  168. type="primary"
  169. @click="changeConfig"
  170. >确认修改配置</el-button
  171. >
  172. </template>
  173. </hc-dialog>
  174. </div>
  175. </template>
  176. <script setup>
  177. import { ref, onMounted } from "vue";
  178. import entryConfig from "../entry-config.vue";
  179. import wbsApi from "~api/desk/wbs";
  180. import mainApi from "~api/project/tree";
  181. import archiveApi from "~api/desk/archiveTree";
  182. import { getArrValue } from "js-fast-way";
  183. import { HcDelMsg } from "hc-vue3-ui";
  184. onMounted(() => {
  185. getPublictreeoptions();
  186. getTesttreeOptions();
  187. });
  188. const tabsKey = ref("1");
  189. const tabsData = ref([
  190. { key: "1", name: "立卷规则" },
  191. { key: "2", name: "工程文件入口配置" },
  192. ]);
  193. const tabsChange = (item) => {
  194. tabsKey.value = item.key;
  195. splitOptions.value = {
  196. sizes: [45, 45],
  197. snapOffset: 0,
  198. minSize: [300, 300],
  199. };
  200. };
  201. const splitOptions = { sizes: [45, 45], snapOffset: 0, minSize: [300, 300] };
  202. //选择公有质检划分树
  203. const publictreeValue = ref("");
  204. const testtreeValue = ref("");
  205. const treeSelectId = ref("");
  206. const treeIdChange = (val) => {
  207. getSecondTreeData(val);
  208. getRightData(val);
  209. treeSelectId.value = val;
  210. if (testtreeValue.value) {
  211. testtreeValue.value = "";
  212. }
  213. };
  214. const testTreeIdChange = (val) => {
  215. treeSelectId.value = val;
  216. getSecondTreeData(val);
  217. if (publictreeValue.value) {
  218. publictreeValue.value = "";
  219. }
  220. };
  221. const publictreeOptions = ref([]);
  222. const testtreeOptions = ref([]);
  223. const getPublictreeoptions = async () => {
  224. const { code, data } = await wbsApi.getWbsList(1);
  225. if (code == 200) {
  226. publictreeOptions.value = getArrValue(data);
  227. }
  228. };
  229. const getTesttreeOptions = async () => {
  230. const { code, data } = await wbsApi.getWbsList(2);
  231. if (code == 200) {
  232. testtreeOptions.value = getArrValue(data);
  233. }
  234. };
  235. //立卷规则树
  236. const secondTreeRef = ref(null);
  237. const secondTreeData = ref([]);
  238. const secondTreeProps = {
  239. label: "title",
  240. };
  241. //立卷规则树右键菜单
  242. const secondTreeMenu = (_, resolve) => {
  243. resolve([
  244. { icon: "eye", label: "查看配置", key: "rank" },
  245. { icon: "delete-bin", label: "删除", key: "del" },
  246. ]);
  247. };
  248. //立卷规则树
  249. const treeLoading = ref(false);
  250. const getSecondTreeData = async (wbsId) => {
  251. treeLoading.value = true;
  252. const { data } = await mainApi.allTree({
  253. projectId: 0,
  254. wbsId,
  255. });
  256. treeLoading.value = false;
  257. secondTreeData.value = getArrValue(data);
  258. };
  259. const secondTreeMenuClick = async ({ key, data, node }) => {
  260. if (key === "rank") {
  261. configInfo.value = null;
  262. const {
  263. data: res,
  264. code,
  265. msg,
  266. } = await archiveApi.getArchiveAutoRule({
  267. nodeId: data.id, //归档树节点的id 或者 挂载wbs节点的ID(具体哪个ID待定)
  268. iswbsNode: data.iswbsNode, //是否是wbs节点
  269. projectId: 0, // 系统级为0 项目级为项目id
  270. wbsNode2ArchiveTreeNodeId: data.wbsNode2ArchiveTreeNodeId, // 这个树节点里面有(iswbsNode为true需传)
  271. wbsId: treeSelectId.value, // 这个就是一开始上面选择划分树的id(iswbsNode为true需传)
  272. });
  273. console.log(res, "res");
  274. if (code == 200 && msg == "操作成功") {
  275. if (res.type) {
  276. configInfo.value = res;
  277. } else if (res.archiveAutoType) {
  278. configInfo.value = {
  279. type: 2,
  280. data: [res.data],
  281. };
  282. checkedKeys.value = data?.selectNodeIds.split(",");
  283. } else {
  284. configInfo.value = {};
  285. }
  286. configVisible.value = true;
  287. }
  288. } else if (key === "del") {
  289. HcDelMsg(async (resolve) => {
  290. const { code } = await archiveApi.removeArchiveAutoRule({
  291. nodeId: data.id,
  292. iswbsNode: data.iswbsNode, //是否是wbs节点 flase 不是 true 是 (先false,具体怎么区分后面再看)
  293. projectId: 0, // 系统级为0 项目级为项目id
  294. });
  295. resolve(); //关闭弹窗的回调
  296. if (code !== 200) return;
  297. window.$message.success("删除成功");
  298. getSecondTreeData(treeSelectId.value);
  299. }).then();
  300. }
  301. };
  302. const titleName = ref("");
  303. const archiveAutoType = ref(1);
  304. const setName = (type) => {
  305. switch (type) {
  306. case 1:
  307. archiveAutoType.value = 1;
  308. titleName.value = "设置最高并卷层级";
  309. break;
  310. case 2:
  311. archiveAutoType.value = 2;
  312. titleName.value = "设置分类并卷层级";
  313. break;
  314. case 3:
  315. archiveAutoType.value = 3;
  316. titleName.value = "设置单独并卷层级";
  317. break;
  318. }
  319. };
  320. const highVisible = ref(false);
  321. const checkList = ref([]);
  322. const nodesList = ref([]);
  323. //设置为最高并卷层级
  324. const setClick = (type) => {
  325. if (!publictreeValue.value && !testtreeValue.value) {
  326. window.$message({
  327. message: "请先在下拉框选择树,在勾选树节点,再进行设置",
  328. type: "warning",
  329. });
  330. return false;
  331. }
  332. const treeRef = secondTreeRef.value?.getRef(); //树的原始ref
  333. const nodes = treeRef.getCheckedNodes(); //获取选中的节点
  334. console.log(nodes, "nodes");
  335. if (nodes.length < 1) {
  336. window.$message({
  337. message: "请先勾选节点,再进行设置",
  338. type: "warning",
  339. });
  340. return false;
  341. }
  342. let ids = [];
  343. nodes.forEach((element) => {
  344. element.pathName = getTreeNodePath(element, "secondTreeRef");
  345. ids.push(element.id);
  346. });
  347. console.log(nodes, "nodes");
  348. checkList.value = ids;
  349. nodesList.value = nodes;
  350. setName(type);
  351. highVisible.value = true;
  352. };
  353. //获取树节点名字路径
  354. const getTreeNodePath = (node, refName) => {
  355. let nodeInfo = secondTreeRef.value.treeRef.getNode(node.id);
  356. let pathArr = [];
  357. while (nodeInfo.parent) {
  358. pathArr.push(nodeInfo.data.title);
  359. nodeInfo = nodeInfo.parent;
  360. }
  361. return pathArr.reverse().join("/");
  362. };
  363. const setRecordsHandle = async () => {
  364. const { code, msg } = await archiveApi.saveArchiveAutoRule({
  365. archiveAutoType: archiveAutoType.value, //最高1 分类2 独立3
  366. selectNodeIds: checkList.value.join(","), //鼠标选择的节点ID(只要鼠标选择的节点,选择节点的下级子节点那种不要),逗号拼接
  367. iswbsNode: nodesList.value[0].iswbsNode, //是否是wbs节点
  368. projectId: 0, // 系统级为0 项目级为项目id
  369. });
  370. if (code == 200 && msg == "操作成功") {
  371. window.$message({
  372. type: "success",
  373. message: "设置成功",
  374. });
  375. if (publictreeValue.value) {
  376. treeIdChange(treeSelectId.value);
  377. } else {
  378. testTreeIdChange(treeSelectId.value);
  379. }
  380. highVisible.value = false;
  381. }
  382. };
  383. //查看配置
  384. const configtree = ref(null);
  385. const configVisible = ref(false);
  386. const configInfo = ref({});
  387. const checkedKeys = ref([]);
  388. const configCheckChange = () => {};
  389. const changeConfig = () => {};
  390. //工程文件入口配置
  391. const rightData = ref([]);
  392. const getRightData = async (id) => {
  393. const { data, code } = await archiveApi.archiveTreetree({
  394. projectId: 0,
  395. wbsId: id,
  396. });
  397. if (code == 200) {
  398. rightData.value = data;
  399. }
  400. };
  401. </script>
  402. <style scoped lang="scss">
  403. .hc-tab-scroll-class-second {
  404. position: relative;
  405. height: calc(100% - 42px);
  406. }
  407. .hc-tab-scroll-class-second :deep(.hc-tree-node .data-custom-tree-node .label) {
  408. display: flex;
  409. }
  410. .hc-tab-scroll-class-second :deep(.config_type) {
  411. position: relative;
  412. height: 18px;
  413. width: 18px;
  414. font-size: 14px;
  415. display: flex;
  416. align-items: center;
  417. justify-content: center;
  418. background: #fb5c5c;
  419. color: white;
  420. border-radius: 3px;
  421. margin-right: 5px;
  422. }
  423. </style>