index.vue 13 KB

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