index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <!-- 动环设备管理 -->
  2. <template>
  3. <div class="app-container">
  4. <el-row :gutter="20">
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @click="clicktreenode"
  9. :customRequest="treeData"
  10. searchPlaceHolder="输入关键字进行过滤"
  11. :expand-on-click-node="true"
  12. node-key="id"
  13. :default-expanded-keys="topItemKeys"
  14. accordion
  15. :defaultProps="defaultProps"
  16. :showLowerCheck="false"
  17. :renderContent="renderContent"
  18. >
  19. </org-tree>
  20. </el-col>
  21. <el-col :span="20" :xs="24">
  22. <el-form
  23. :model="queryParams"
  24. ref="search"
  25. size="small"
  26. :inline="true"
  27. v-show="showSearch"
  28. label-width="100px"
  29. >
  30. <el-form-item prop="itemName" label="检查项">
  31. <el-input
  32. v-model="queryParams.itemName"
  33. placeholder="请输入内容"
  34. maxlength="50"
  35. clearable
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item prop="pointName" label="检查内容">
  39. <el-input
  40. v-model="queryParams.pointName"
  41. placeholder="请输入检查内容"
  42. maxlength="50"
  43. clearable
  44. ></el-input>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button
  48. type="primary"
  49. icon="el-icon-search"
  50. size="mini"
  51. @click="refresh"
  52. v-hasPermi="['safetycheck:ruleManager']"
  53. >搜索</el-button
  54. >
  55. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  56. >重置</el-button
  57. >
  58. </el-form-item>
  59. </el-form>
  60. <!-- 按纽 -->
  61. <el-row :gutter="10" class="mb8">
  62. <el-col :span="1.5">
  63. <el-button
  64. type="primary"
  65. @click="onAddItem()"
  66. :disabled="rule ? false : true"
  67. v-hasPermi="['safetycheck:ruleManager:add']"
  68. v-if="rule && rule.orgId == orgId && rule.ruleStatus == 0"
  69. >新 增</el-button
  70. >
  71. <!-- <el-button
  72. type="primary".
  73. @click="onSelect()"
  74. >选择</el-button
  75. > -->
  76. <el-button
  77. type="warning"
  78. @click="dakai"
  79. :disabled="rule ? false : true"
  80. >{{ expandAll ? "收起所有行" : "展开所有行" }}</el-button
  81. >
  82. </el-col>
  83. <right-toolbar
  84. :showSearch.sync="showSearch"
  85. @queryTable="getList"
  86. :columns="columns"
  87. ></right-toolbar>
  88. </el-row>
  89. <el-table
  90. :data="tableData"
  91. border
  92. :default-expand-all="expandAll"
  93. v-if="fresh"
  94. style="width: 100%"
  95. v-loading="loading"
  96. >
  97. <el-table-column type="expand">
  98. <template slot-scope="props">
  99. <el-table
  100. :data="props.row.pointDtoList"
  101. border
  102. style="width: 100%"
  103. >
  104. <el-table-column
  105. prop="name"
  106. label="检查内容"
  107. v-if="columns[3].visible"
  108. >
  109. </el-table-column>
  110. <el-table-column
  111. prop="areaName"
  112. label="检查区域"
  113. v-if="columns[4].visible"
  114. >
  115. </el-table-column>
  116. <!-- <el-table-column prop="dataTypeName" label="数据类型">
  117. </el-table-column>
  118. <el-table-column prop="degreeRiskName" label="风险等级">
  119. </el-table-column> -->
  120. </el-table>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. type="index"
  125. label="序号"
  126. width="80"
  127. v-if="columns[0].visible"
  128. >
  129. </el-table-column>
  130. <el-table-column prop="name" label="检查项" v-if="columns[1].visible">
  131. </el-table-column>
  132. <!-- <el-table-column prop="itemDesc" label="标准及要求">
  133. </el-table-column> -->
  134. <el-table-column
  135. prop="pointNums"
  136. label="检查内容数量"
  137. v-if="columns[2].visible"
  138. >
  139. </el-table-column>
  140. <el-table-column
  141. label="操作"
  142. width="140"
  143. v-if="rule && rule.orgId == orgId && rule.ruleStatus == 0"
  144. >
  145. <template slot-scope="scope">
  146. <el-button
  147. type="text"
  148. size="small"
  149. icon="el-icon-edit-outline"
  150. @click="onEditItem(scope.row.id)"
  151. v-hasPermi="['safetycheck:ruleManager:edit']"
  152. >编辑</el-button
  153. >
  154. <el-button
  155. type="text"
  156. size="small"
  157. slot="reference"
  158. icon="el-icon-delete"
  159. @click="deldata(scope.row.id)"
  160. v-hasPermi="['safetycheck:ruleManager:remove']"
  161. >删除</el-button
  162. >
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. <pagination
  167. v-show="total > 0"
  168. :total="total"
  169. :page.sync="queryParams.pageNum"
  170. :limit.sync="queryParams.pageSize"
  171. @pagination="getList"
  172. />
  173. </el-col>
  174. </el-row>
  175. <dialog-edit
  176. ref="dialogEdit"
  177. :rule="rule"
  178. :pointDataSource="dict.type.point_data_source"
  179. @success="onSuccess"
  180. ></dialog-edit>
  181. <SelectPoint ref="DialogSelect" @success="onSuccess" orgType="4">
  182. </SelectPoint>
  183. </div>
  184. </template>
  185. <script>
  186. import { mapGetters } from "vuex";
  187. import { page, treeData, del } from "@/api/safetycheck/ruleManager.js";
  188. import DialogEdit from "./dialog.editItem.vue";
  189. import SelectPoint from "./dialog.select.point.vue";
  190. import OrgTree from "@/components/orgTree";
  191. export default {
  192. name: "safetycheckRuleManager",
  193. props: [],
  194. dicts: ["point_data_source"],
  195. data() {
  196. return {
  197. queryParams: {
  198. ruleId: null,
  199. itemName: null,
  200. pointName: null,
  201. pageNum: 1,
  202. pageSize: 10,
  203. },
  204. filterText: null,
  205. showSearch: true,
  206. rule: null, //选中的内容库
  207. // orgOfRule:null,//选中内容库
  208. expandAll: false,
  209. fresh: true,
  210. // checked: false,
  211. // item: {
  212. // label: "",
  213. // value: "",
  214. // },
  215. treedata: [],
  216. defaultProps: {
  217. children: "children",
  218. label: "label",
  219. },
  220. tableData: [],
  221. loading: false,
  222. total: 0,
  223. topItemKeys: [],
  224. // defaultProps: {
  225. // children: "children",
  226. // label: "label",
  227. // },
  228. columns: [
  229. { key: 0, label: `序号`, visible: true },
  230. { key: 1, label: `检查项`, visible: true },
  231. { key: 2, label: `检查内容数量`, visible: true },
  232. { key: 3, label: `检查内容`, visible: true },
  233. { key: 4, label: `检查区域`, visible: true },
  234. ],
  235. currentOrgId: null,
  236. };
  237. },
  238. components: { DialogEdit, SelectPoint, OrgTree },
  239. computed: {
  240. ...mapGetters(["orgId"]),
  241. // ...mapState(["org", "loginUser"]),
  242. },
  243. watch: {
  244. filterText(val) {
  245. this.$refs.tree.filter(val);
  246. },
  247. },
  248. async created() {
  249. // this.OID = this.loginUser.org.id;
  250. // await this.gettreelist();
  251. // await this.getList()
  252. // await this.getassetlist();
  253. },
  254. mounted() {},
  255. methods: {
  256. treeData,
  257. dakai() {
  258. this.expandAll = !this.expandAll;
  259. this.fresh = false;
  260. this.$nextTick(() => {
  261. this.fresh = true;
  262. });
  263. },
  264. filterNode(value, data) {
  265. if (!value) return true;
  266. return data.label.indexOf(value) !== -1;
  267. },
  268. async refresh() {
  269. this.currentPage = 1;
  270. this.getList();
  271. },
  272. async getList() {
  273. if (!this.queryParams.ruleId) {
  274. this.$message.warning("请先选择一个检查内容库定义");
  275. return;
  276. }
  277. this.loading = true;
  278. const data = await page(this.queryParams);
  279. this.tableData = data.rows;
  280. this.total = Number.parseInt(data.total);
  281. this.expandAll = false;
  282. this.loading = false;
  283. },
  284. handleSizeChange(val) {
  285. this.pagesize = val;
  286. this.getList();
  287. },
  288. handleCurrentChange(val) {
  289. this.currentPage = val;
  290. this.getList();
  291. },
  292. clicktreenode(data, node) {
  293. this.tableData = [];
  294. this.rule = null;
  295. this.queryParams.ruleId = null;
  296. if (!data.isRule) {
  297. return;
  298. }
  299. this.expandAll = false;
  300. this.fresh = false;
  301. this.$nextTick(() => {
  302. this.fresh = true;
  303. });
  304. this.queryParams.ruleId = data.id;
  305. this.rule = data;
  306. this.rule.orgId = node.parent.data.id;
  307. if (this.rule.ruleStatus != 0) {
  308. this.$message.info("履职内容库已禁用,无法编辑履职项、履职内容");
  309. }
  310. this.refresh();
  311. },
  312. deldata(val) {
  313. this.$modal
  314. .confirm("确定删除检查内容库定义?")
  315. .then(() => {
  316. return del(val);
  317. })
  318. .then(() => {
  319. this.$message.info("删除成功");
  320. this.getList();
  321. });
  322. },
  323. renderContent(h, { node, data, store }) {
  324. if (data.isRule == 0) {
  325. return (
  326. <span class="custom-tree-node">
  327. <span class="show-ellipsis">{data.shortName}</span>
  328. </span>
  329. );
  330. } else {
  331. return (
  332. <span class="custom-tree-node">
  333. <span style="display: flex">
  334. <i
  335. class="el-icon-s-management"
  336. style="color: #008cd6; padding-top: 3px"
  337. ></i>
  338. <span class="show-ellipsis">{data.shortName}</span>
  339. </span>
  340. </span>
  341. );
  342. }
  343. },
  344. /** 重置按钮操作 */
  345. resetQuery() {
  346. this.resetForm("search");
  347. // this.queryParams.ruleId = undefined;
  348. // this.$refs.tree.setCurrentKey(null);
  349. this.getList();
  350. },
  351. onAddItem() {
  352. if (!this.rule) {
  353. this.$message.warning("请先选择检查内容库");
  354. return;
  355. }
  356. this.$refs.dialogEdit.show(null);
  357. },
  358. onEditItem(itemId) {
  359. this.$refs.dialogEdit.show(itemId);
  360. },
  361. onSelect() {
  362. this.$refs.DialogSelect.show();
  363. },
  364. onSuccess() {
  365. this.refresh();
  366. },
  367. },
  368. };
  369. </script>
  370. <style lang="scss" scoped>
  371. .show-ellipsis {
  372. display: block;
  373. width: 180px;
  374. overflow: hidden;
  375. white-space: nowrap;
  376. text-overflow: ellipsis;
  377. }
  378. .search {
  379. display: flex;
  380. flex-wrap: wrap;
  381. & > div {
  382. width: 25%;
  383. display: flex;
  384. align-items: center;
  385. margin-bottom: 12px;
  386. & > span:first-child {
  387. display: inline-block;
  388. min-width: 70px;
  389. font-size: 14px;
  390. color: #606266;
  391. }
  392. &:nth-child(2),
  393. &:nth-child(3) {
  394. margin-left: 15px;
  395. }
  396. &:nth-child(3) > span {
  397. display: inline-block;
  398. min-width: 100px;
  399. font-size: 14px;
  400. color: #606266;
  401. }
  402. &:nth-child(1) > span {
  403. display: inline-block;
  404. min-width: 100px;
  405. font-size: 14px;
  406. color: #606266;
  407. }
  408. &:nth-child(1) {
  409. }
  410. }
  411. }
  412. .box {
  413. border: 1px solid #eee;
  414. margin-bottom: 20px;
  415. border-radius: 5px;
  416. padding: 10px;
  417. min-height: 120px;
  418. & > p {
  419. font-size: 16px;
  420. font-weight: bold;
  421. margin-bottom: 15px;
  422. }
  423. }
  424. .item {
  425. margin-bottom: 14px;
  426. }
  427. ::v-deep .el-table__expanded-cell[class*="cell"] {
  428. padding: 0;
  429. padding-left: 47px;
  430. }
  431. ::v-deep .formbox {
  432. display: flex;
  433. flex-wrap: wrap;
  434. .el-form-item {
  435. width: 50%;
  436. }
  437. }
  438. </style>