index.vue 12 KB

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