index.vue 13 KB

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