hgxsc.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="hgxsc">
  3. <el-form
  4. :model="ruleForm"
  5. ref="ruleForm"
  6. label-width="100px"
  7. :rules="rules"
  8. >
  9. <el-form-item label="选址范围:" prop="xzmj">
  10. <range type="hgxfx" :keys="['hx', 'sc']" class="range" ref="range" />
  11. </el-form-item>
  12. <!-- <div class="block-title">基本信息</div> -->
  13. <el-form-item label="项目名称:" prop="xmmc">
  14. <el-input
  15. v-model="ruleForm.xmmc"
  16. size="mini"
  17. placeholder="请输入项目名称"
  18. ></el-input>
  19. </el-form-item>
  20. <el-form-item label="项目类型:" prop="xmlx">
  21. <el-input
  22. v-model="ruleForm.xmlx"
  23. size="mini"
  24. placeholder="请输入项目类型"
  25. ></el-input>
  26. </el-form-item>
  27. <el-form-item label="建设单位:" prop="jsdw">
  28. <el-input
  29. v-model="ruleForm.jsdw"
  30. size="mini"
  31. placeholder="请输入建设单位"
  32. ></el-input>
  33. </el-form-item>
  34. </el-form>
  35. <div class="site-title">
  36. <div class="siteCon">
  37. <div class="site_Icon"></div>
  38. <span>分析因子</span>
  39. </div>
  40. <div
  41. v-show="$store.getters.name == 'admin'"
  42. class="posi-abs pointer"
  43. style="right: 0; top: 1px; color: #409eff"
  44. @click="updateScx"
  45. >
  46. 关联资源目录
  47. </div>
  48. </div>
  49. <div class="treeDiv">
  50. <el-tree
  51. :data="treedata"
  52. ref="tree"
  53. show-checkbox
  54. node-key="bsm"
  55. :props="defaultProps"
  56. :default-expanded-keys="xz"
  57. >
  58. </el-tree>
  59. </div>
  60. <div class="bottomBtns">
  61. <span class="clearBtn" @click="reset">取消</span>
  62. <span class="sureBtn" @click="submitData">确定</span>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import { Add, GetScx, UpdateScx } from "@/api/ghss/hgxfx.js";
  68. import { Message, MessageBox } from "element-ui";
  69. import range from "@/components/mapview/range.vue"; ///mapview/range
  70. import hgxfx from "../../../../static/data/ghss/data.js";
  71. export default {
  72. components: {
  73. range,
  74. },
  75. props: {},
  76. data() {
  77. return {
  78. xz: [],
  79. treedata: [
  80. {
  81. id: 1,
  82. label: "一级控制线",
  83. children: [],
  84. },
  85. {
  86. id: 2,
  87. label: "二级控制线",
  88. children: [],
  89. },
  90. ],
  91. defaultProps: {
  92. children: "children",
  93. label: "ysmc",
  94. },
  95. ruleForm: {
  96. xmmc: "",
  97. jsdw: "",
  98. xmlx: "",
  99. // xzdw: "",
  100. ydxz_bsm: "",
  101. yjydlx: "",
  102. fwlx: 1,
  103. xzfw: "",
  104. xzmj: 0,
  105. },
  106. rules: {
  107. xzmj: [{ required: true, message: "请填写范围的数据" }],
  108. xmmc: [
  109. { required: true, message: "请输入项目名称", trigger: "blur" },
  110. {
  111. min: 3,
  112. max: 50,
  113. message: "长度在 3 到 50 个字符",
  114. trigger: "blur",
  115. },
  116. ],
  117. jsdw: [{ required: true, message: "请输入建设单位", trigger: "blur" }],
  118. xmlx: [{ required: true, message: "请输入项目类型", trigger: "blur" }],
  119. },
  120. options: [],
  121. };
  122. },
  123. mounted() {
  124. this.getKzx();
  125. },
  126. methods: {
  127. //获取检查要素
  128. getKzx() {
  129. GetScx().then((res) => {
  130. if (res) {
  131. this.treedata = this.tranListToTreeData(res.data, "0");
  132. res.data.forEach((item) => {
  133. if (item.kzxjb == 1) this.xz.push(item.bsm);
  134. });
  135. setTimeout(() => {
  136. this.$refs.tree.setCheckedKeys(this.xz);
  137. }, 1);
  138. }
  139. });
  140. },
  141. tranListToTreeData(list, pbsm) {
  142. var map = {};
  143. list.forEach((item) => {
  144. if (map[item.pbsm]) map[item.pbsm].push(item);
  145. else map[item.pbsm] = [item];
  146. });
  147. list.forEach((item) => {
  148. if (map[item.pbsm]) item.children = map[item.bsm];
  149. });
  150. map = list.filter((item) => {
  151. return item.pbsm == pbsm;
  152. });
  153. return map;
  154. },
  155. updateScx() {
  156. UpdateScx().then((res) => {
  157. if (res.statuscode == 200) {
  158. Message.success(res.message);
  159. } else {
  160. Message.error(res.message);
  161. }
  162. });
  163. },
  164. setydlx() {
  165. this.ruleForm.yjydlx = this.$refs.ydcascader
  166. .getCheckedNodes()[0]
  167. .pathLabels.join(",");
  168. this.$refs.ydcascader.togglePopperVisible();
  169. },
  170. reset() {
  171. this.ruleForm = {
  172. xmmc: "",
  173. jsdw: "",
  174. xmlx: "",
  175. // xzdw: "",
  176. ydxz_bsm: "",
  177. yjydlx: "",
  178. scxList: [],
  179. fwlx: 1,
  180. xzfw: "",
  181. xzmj: 0,
  182. };
  183. this.$refs.range.reset();
  184. setTimeout(() => {
  185. this.$refs.tree.setCheckedKeys(this.xz);
  186. }, 1);
  187. },
  188. submitData() {
  189. //更新范围
  190. var _temp = this.$refs.range.getRange();
  191. this.ruleForm.xzfw = _temp.xzfw;
  192. this.ruleForm.xzmj = _temp.xzmj || hgxfx.xzmj;
  193. this.$refs.ruleForm.validate((valid) => {
  194. if (valid) {
  195. this.getCheckedNodes();
  196. if (this.ruleForm.scxList.length == 0) {
  197. Message.warning("至少选择一个项目信息");
  198. }
  199. MessageBox.confirm("是否开始进行合规性检查?", "合规性检查", {
  200. confirmButtonText: "确定",
  201. cancelButtonText: "取消",
  202. type: "warning",
  203. }).then(() => {
  204. this.$emit("updateParent", "loading", true);
  205. Add({ ...this.ruleForm }).then((res) => {
  206. if (res.success) {
  207. this.$emit("updateParent", "nowObj", this.ruleForm);
  208. this.$emit("updateParent", "rzBsm", res.data);
  209. this.reset();
  210. } else {
  211. Message.warning(res.message);
  212. }
  213. this.$emit("updateParent", "loading", false);
  214. });
  215. });
  216. }
  217. });
  218. },
  219. getCheckedNodes() {
  220. // .getCheckedNodes(true) 是否只是叶子节点
  221. this.ruleForm.scxList = this.$refs.tree.getCheckedNodes().map((item) => {
  222. return { scxbsm: item.bsm };
  223. });
  224. },
  225. },
  226. watch: {},
  227. };
  228. </script>
  229. <style lang="scss" scoped>
  230. .hgxsc {
  231. height: 100%;
  232. line-height: 40px;
  233. .rangDiv {
  234. width: 100%;
  235. // height: 100px;
  236. display: flex;
  237. justify-content: space-between;
  238. }
  239. .range {
  240. flex: 1;
  241. width: 100%;
  242. // position: absolute;
  243. // left: 100px;
  244. }
  245. .treeDiv {
  246. width: 100%;
  247. height: calc(100% - 390px);
  248. padding: 7px;
  249. margin-bottom: 10px;
  250. overflow-y: auto;
  251. }
  252. }
  253. /deep/ .el-input .el-input--mini .el-input--suffix {
  254. width: 100%;
  255. }
  256. /deep/ .el-select {
  257. width: 100%;
  258. }
  259. /deep/ .el-form-item__error {
  260. top: 32px !important;
  261. }
  262. </style>