index.vue 11 KB

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