index.vue 12 KB

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