index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <!-- <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. :customRequest="orgTree"
  12. ></org-tree>
  13. </el-col> -->
  14. <el-col :span="24" :xs="24">
  15. <div class="main-right-box">
  16. <!-- 搜索条件 -->
  17. <div class="main-search-box">
  18. <el-form
  19. :model="queryParams"
  20. ref="search"
  21. size="small"
  22. :inline="true"
  23. v-show="showSearch"
  24. >
  25. <el-form-item label="发布机构">
  26. <org-tree
  27. v-model="queryParams.orgId"
  28. @defaultKey="getDefaultKey"
  29. @checkChange="checkChange"
  30. @click="clickTreeNode"
  31. :customRequest="orgTree"
  32. ref="orgTree"
  33. ></org-tree>
  34. </el-form-item>
  35. <el-form-item prop="name" label="检查手册名称" label-width="100">
  36. <el-input
  37. v-model="queryParams.name"
  38. :maxlength="50"
  39. placeholder="请输入检查手册名称"
  40. clearable
  41. />
  42. </el-form-item>
  43. <el-form-item prop="orgType" label="受检机构类型">
  44. <el-select
  45. prop="orgType"
  46. label="受检机构类型"
  47. v-model="queryParams.orgType"
  48. placeholder="请选择受检机构类型"
  49. clearable
  50. >
  51. <el-option
  52. v-for="item in dict.type.sys_org_type"
  53. :key="item.value"
  54. :label="item.label"
  55. :value="item.value"
  56. >
  57. </el-option>
  58. </el-select>
  59. </el-form-item>
  60. </el-form>
  61. <!-- 按纽 -->
  62. <el-row :gutter="10">
  63. <el-col :span="1.5">
  64. <el-button
  65. type="primary"
  66. icon="el-icon-search"
  67. size="mini"
  68. @click="refresh"
  69. v-hasPermi="['safetycheck:rule:query']"
  70. >搜索</el-button
  71. >
  72. <el-button
  73. type="primary"
  74. icon="el-icon-refresh"
  75. size="mini"
  76. @click="resetQuery"
  77. >重置</el-button
  78. >
  79. <el-button
  80. type="primary"
  81. icon="el-icon-plus"
  82. size="mini"
  83. @click="handleAdd()"
  84. v-hasPermi="['safetycheck:rule:add']"
  85. >新增检查手册</el-button
  86. >
  87. </el-col>
  88. <right-toolbar
  89. :showSearch.sync="showSearch"
  90. @queryTable="getList"
  91. >
  92. </right-toolbar>
  93. </el-row>
  94. </div>
  95. <el-table
  96. size="small"
  97. border
  98. v-loading="loading"
  99. :data="pageData"
  100. @selection-change="handleSelectionChange"
  101. height="646"
  102. >
  103. <el-table-column
  104. align="center"
  105. type="index"
  106. label="序号"
  107. width="60"
  108. v-if="columns[0].visible"
  109. >
  110. <template slot-scope="scope">
  111. {{
  112. (queryParams.pageNum - 1) * queryParams.pageSize +
  113. scope.$index +
  114. 1
  115. }}
  116. </template>
  117. </el-table-column>
  118. <el-table-column
  119. align="center"
  120. prop="name"
  121. label="检查手册名称"
  122. show-overflow-tooltip
  123. v-if="columns[1].visible"
  124. ></el-table-column>
  125. <el-table-column
  126. align="center"
  127. prop="orgType"
  128. label="受检机构类型"
  129. width="200"
  130. v-if="columns[2].visible"
  131. >
  132. <template slot-scope="r"
  133. >{{ getLabel(dict.type.sys_org_type, r.row.orgType) }}
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. align="center"
  138. prop="orgName"
  139. label="发布机构"
  140. v-if="columns[3].visible"
  141. ></el-table-column>
  142. <el-table-column
  143. align="center"
  144. prop="status"
  145. label="状态"
  146. width="150"
  147. v-if="columns[4].visible"
  148. >
  149. <template slot-scope="r">
  150. <span>{{ getLabel(dict.type.rule_status, r.row.status) }}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column
  154. align="center"
  155. prop="remark"
  156. label="备注"
  157. show-overflow-tooltip
  158. v-if="columns[5].visible"
  159. ></el-table-column>
  160. <el-table-column align="center" label="操作" width="300">
  161. <template slot-scope="r">
  162. <div>
  163. <el-button
  164. size="mini"
  165. type="text"
  166. icon="el-icon-edit-outline"
  167. @click="onEdit(r.row.id)"
  168. v-if="orgId == r.row.orgId"
  169. v-hasPermi="['safetycheck:rule:edit']"
  170. >编辑手册</el-button
  171. >
  172. <el-button
  173. size="mini"
  174. type="text"
  175. icon="el-icon-edit-outline"
  176. @click="onManageContent(r.row.id,'edit')"
  177. v-if="r.row.status == 0 && orgId == r.row.orgId"
  178. v-hasPermi="['safetycheck:rule:contentmanage']"
  179. >管理检查内容</el-button
  180. >
  181. <el-button
  182. size="mini"
  183. type="text"
  184. icon="el-icon-view"
  185. @click="onManageContent(r.row.id,'view')"
  186. v-if="r.row.status != 0 || orgId != r.row.orgId"
  187. v-hasPermi="['safetycheck:rule:contentmanage']"
  188. >查看检查内容</el-button
  189. >
  190. <el-button
  191. type="text"
  192. size="mini"
  193. slot="reference"
  194. icon="el-icon-delete"
  195. @click="onDel(r.row.id)"
  196. v-if="orgId == r.row.orgId"
  197. v-hasPermi="['safetycheck:rule:remove']"
  198. >删除</el-button
  199. >
  200. </div>
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. <pagination
  205. v-show="total > 0"
  206. :total="total"
  207. :page.sync="queryParams.pageNum"
  208. :limit.sync="queryParams.pageSize"
  209. @pagination="getList"
  210. />
  211. </div>
  212. </el-col>
  213. </el-row>
  214. <dialog-edit
  215. ref="editDialog"
  216. @success="getList()"
  217. :orgTypeOptions="dict.type.sys_org_type"
  218. :statusOptions="dict.type.rule_status"
  219. ></dialog-edit>
  220. </div>
  221. </template>
  222. <script>
  223. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  224. import { mapGetters } from "vuex";
  225. import DialogEdit from "./dialog.edit";
  226. import * as api from "@/api/safetycheck/rule";
  227. import { getLabel } from "./../../commonOption";
  228. import { wholeTreeByType } from "@/api/system/org.js";
  229. export default {
  230. name: "safetycheckruletype",
  231. dicts: ["sys_org_type", "rule_status"],
  232. components: {
  233. DialogEdit,
  234. OrgTree,
  235. },
  236. data() {
  237. const { params, query } = this.$route;
  238. return {
  239. isShow: false,
  240. loading: false,
  241. ids: [],
  242. // 非单个禁用
  243. single: true,
  244. // 非多个禁用
  245. multiple: true,
  246. // 显示搜索条件
  247. showSearch: true,
  248. total: 0,
  249. queryParams: {
  250. orgId: null,
  251. name: null,
  252. type: null,
  253. orgType: null,
  254. checkSub: true,
  255. pageNum: 1,
  256. pageSize: 10,
  257. ...query,
  258. },
  259. pageData: [],
  260. // 列信息
  261. columns: [
  262. { key: 0, label: `序号`, visible: true },
  263. { key: 1, label: `检查库名称`, visible: true },
  264. { key: 2, label: `检查机构类型`, visible: true },
  265. { key: 3, label: `发布机构`, visible: true },
  266. { key: 4, label: `状态`, visible: true },
  267. { key: 5, label: `备注`, visible: true },
  268. ],
  269. };
  270. },
  271. props: {},
  272. watch: {},
  273. computed: {
  274. ...mapGetters(["orgId"]),
  275. },
  276. methods: {
  277. getLabel,
  278. orgTree() {
  279. return wholeTreeByType(3);
  280. },
  281. refresh() {
  282. this.queryParams.pageNum = 1;
  283. this.getList();
  284. },
  285. getList() {
  286. this.loading = true;
  287. console.info(this.dict.type);
  288. this.pageData = [];
  289. api
  290. .list(this.queryParams)
  291. .then((response) => {
  292. this.pageData = response.rows;
  293. this.total = response.total;
  294. this.loading = false;
  295. })
  296. .catch(() => {
  297. this.loading = false;
  298. });
  299. },
  300. getDefaultKey(key) {
  301. this.queryParams.orgId = key;
  302. this.getList();
  303. },
  304. handleAdd(id, other = {}) {
  305. this.$refs.editDialog.show(id, other);
  306. },
  307. onEdit(id, other = {}) {
  308. this.$refs.editDialog.show(id, other);
  309. },
  310. onManageContent(id,type) {
  311. let path = `/core/safetycheck/rule/content/${id}`;
  312. //路由名称:safetycheckRuleManager
  313. this.$router.push({ name:"safetycheckRuleManager",params:{id:id,showType:type}});
  314. //this.$router.push(path);
  315. },
  316. onDel(id) {
  317. this.$modal
  318. .confirm("确定删除检查手册?")
  319. .then(() => {
  320. return api.remove(id);
  321. })
  322. .then(() => {
  323. this.$message.info("删除成功");
  324. this.getList();
  325. });
  326. },
  327. // 多选框选中数据
  328. handleSelectionChange(selection) {
  329. this.ids = selection.map((item) => item.userId);
  330. this.single = selection.length != 1;
  331. this.multiple = !selection.length;
  332. },
  333. /** 重置按钮操作 */
  334. resetQuery() {
  335. this.resetForm("search");
  336. this.$refs["orgTree"].setSelectTop();
  337. this.queryParams.checkSub = true;
  338. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
  339. // this.$refs.tree.setCurrentKey(null);
  340. this.getList();
  341. },
  342. //单选框状态改变
  343. checkChange(state) {
  344. this.queryParams.checkSub = state;
  345. this.getList();
  346. },
  347. // 节点单击事件
  348. clickTreeNode(data) {
  349. this.queryParams.orgId = data.id;
  350. this.getList();
  351. },
  352. //apimark//
  353. },
  354. mounted() {},
  355. };
  356. </script>
  357. <style lang="scss" scoped>
  358. .search_itemname {
  359. ::v-deep .el-form-item__label {
  360. width: 100px !important;
  361. }
  362. }
  363. </style>