index.vue 8.0 KB

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