index.vue 10 KB

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