index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="采集点名称" prop="checkName">
  5. <el-input v-model="queryParams.checkName" placeholder="请输入采集点名称" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="区域" prop="areaId">
  8. <el-select v-model="queryParams.areaId" placeholder="请选择">
  9. <el-option v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item label="归属部门" prop="orgId">
  13. <treeselect style="width: 160px;" v-model="queryParams.orgId" :options="deptOptions" :show-count="true"
  14. :normalizer="tenantIdnormalizer" :props="{ checkStrictly: true, label: 'name' }" placeholder="请选择归属部门" />
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  18. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  19. </el-form-item>
  20. </el-form>
  21. <el-row :gutter="10" class="mb8">
  22. <el-col :span="1.5">
  23. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  24. v-hasPermi="['system:check:add']">新增</el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  28. v-hasPermi="['system:check:edit']">修改</el-button>
  29. </el-col>
  30. <el-col :span="1.5">
  31. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  32. v-hasPermi="['system:check:remove']">删除</el-button>
  33. </el-col>
  34. <!-- <el-col :span="1.5">
  35. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  36. v-hasPermi="['system:check:export']">导出</el-button>
  37. </el-col> -->
  38. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  39. </el-row>
  40. <el-table v-loading="loading" :data="checkList" @selection-change="handleSelectionChange">
  41. <el-table-column type="selection" width="55" align="center" />
  42. <el-table-column label="采集点名称" align="center" prop="checkName" />
  43. <el-table-column label="区域" align="center" prop="areaName" />
  44. <el-table-column label="机构" align="center" prop="orgName" />
  45. <el-table-column label="修改人" align="center" prop="updateBy" />
  46. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  47. <template slot-scope="scope">
  48. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  49. v-hasPermi="['system:check:edit']">修改</el-button>
  50. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  51. v-hasPermi="['system:check:remove']">删除</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  56. @pagination="getList" />
  57. <!-- 添加或修改区域采集点对话框 -->
  58. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  59. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  60. <el-row>
  61. <el-col :span="16">
  62. <el-form-item label="区域名称">
  63. <el-select v-model="form.areaId" placeholder="请选择区域名称">
  64. <el-option v-for="item in roleOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
  65. </el-select>
  66. </el-form-item>
  67. </el-col>
  68. </el-row>
  69. <el-form-item label="采集点名称" prop="checkName">
  70. <el-input v-model="form.checkName" placeholder="请输入采集点名称" />
  71. </el-form-item>
  72. <el-row>
  73. <el-col :span="16">
  74. <el-form-item label="归属部门" prop="orgId">
  75. <treeselect v-model="form.orgId" :options="deptOptions" :show-count="true" :normalizer="tenantIdnormalizer"
  76. :props="{ checkStrictly: true, label: 'name' }" placeholder="请选择归属部门" />
  77. </el-form-item>
  78. </el-col>
  79. </el-row>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button type="primary" @click="submitForm">确 定</el-button>
  83. <el-button @click="cancel">取 消</el-button>
  84. </div>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import { listCheck, getCheck, delCheck, addCheck, updateCheck } from "@/api/system/check";
  90. import treeselect from '@riophae/vue-treeselect'
  91. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  92. import { deptTreeSelect } from "@/api/system/public";
  93. import { listArea } from "@/api/system/area";
  94. export default {
  95. name: "Check",
  96. components: { treeselect },
  97. dicts: ['sys_normal_disable'],
  98. data() {
  99. return {
  100. // 遮罩层
  101. loading: true,
  102. // 选中数组
  103. ids: [],
  104. // 非单个禁用
  105. single: true,
  106. // 非多个禁用
  107. multiple: true,
  108. // 显示搜索条件
  109. showSearch: true,
  110. //区域
  111. roleOptions: [],
  112. //搜索tree
  113. deptName: null,
  114. // 部门树选项
  115. deptOptions: null,
  116. // 总条数
  117. total: 0,
  118. //区域集合
  119. areaList: [],
  120. // 区域采集点表格数据
  121. checkList: [],
  122. // 弹出层标题
  123. title: "",
  124. // 是否显示弹出层
  125. open: false,
  126. // 查询参数
  127. queryParams: {
  128. pageNum: 1,
  129. pageSize: 10,
  130. checkName: null,
  131. areaId: null,
  132. orgId: null,
  133. updateId: null,
  134. },
  135. // 表单参数
  136. form: {},
  137. // 表单校验
  138. rules: {
  139. },
  140. defaultKeys: []
  141. };
  142. },
  143. created() {
  144. this.getList();
  145. this.getDeptTree();
  146. listArea().then(response => {
  147. this.areaList = response.rows;
  148. })
  149. },
  150. methods: {
  151. /** 查询区域采集点列表 */
  152. getList() {
  153. this.loading = true;
  154. listCheck(this.queryParams).then(response => {
  155. this.checkList = response.rows;
  156. this.total = response.total;
  157. this.loading = false;
  158. });
  159. },
  160. /** 查询部门下拉树结构 */
  161. getDeptTree() {
  162. deptTreeSelect().then(response => {
  163. this.deptOptions = response.data;
  164. console.log(this.deptOptions, ' this.deptOptions')
  165. // this.defaultKeys.push(response.data[0].id);
  166. // this.queryParams.orgId = response.data[0].id;
  167. this.handleQuery();
  168. });
  169. },
  170. tenantIdnormalizer(node, instanceId) {
  171. if (node.children && !node.children.length) {
  172. delete node.children
  173. }
  174. return {
  175. id: node.id,
  176. label: node.name,
  177. children: node.children
  178. }
  179. },
  180. // 取消按钮
  181. cancel() {
  182. this.open = false;
  183. this.reset();
  184. },
  185. // 表单重置
  186. reset() {
  187. this.form = {
  188. id: null,
  189. checkName: null,
  190. areaId: null,
  191. orgId: null,
  192. createTime: null,
  193. updateTime: null,
  194. updateId: null,
  195. createBy: null,
  196. delFlag: null,
  197. updateBy: null
  198. };
  199. this.resetForm("form");
  200. },
  201. /** 搜索按钮操作 */
  202. handleQuery() {
  203. this.queryParams.pageNum = 1;
  204. this.getList();
  205. },
  206. /** 重置按钮操作 */
  207. resetQuery() {
  208. this.resetForm("queryForm");
  209. this.handleQuery();
  210. },
  211. // 多选框选中数据
  212. handleSelectionChange(selection) {
  213. this.ids = selection.map(item => item.id)
  214. this.single = selection.length !== 1
  215. this.multiple = !selection.length
  216. },
  217. /** 新增按钮操作 */
  218. handleAdd() {
  219. this.reset();
  220. getCheck('').then(response => {
  221. this.roleOptions = response.areas;
  222. this.open = true;
  223. this.title = "添加";
  224. this.form.password = this.initPassword;
  225. });
  226. },
  227. /** 修改按钮操作 */
  228. handleUpdate(row) {
  229. this.reset();
  230. const id = row.id || this.ids
  231. getCheck(id).then(response => {
  232. this.form = response.data;
  233. this.roleOptions = response.areas;
  234. this.open = true;
  235. this.title = "修改区域采集点";
  236. });
  237. },
  238. /** 提交按钮 */
  239. submitForm() {
  240. this.$refs["form"].validate(valid => {
  241. if (valid) {
  242. if (this.form.id != null) {
  243. updateCheck(this.form).then(response => {
  244. this.$modal.msgSuccess("修改成功");
  245. this.open = false;
  246. this.getList();
  247. });
  248. } else {
  249. addCheck(this.form).then(response => {
  250. this.$modal.msgSuccess("新增成功");
  251. this.open = false;
  252. this.getList();
  253. });
  254. }
  255. }
  256. });
  257. },
  258. /** 删除按钮操作 */
  259. handleDelete(row) {
  260. const ids = row.id || this.ids;
  261. this.$modal.confirm('是否确认删除区域采集点编号为"' + ids + '"的数据项?').then(function () {
  262. return delCheck(ids);
  263. }).then(() => {
  264. this.getList();
  265. this.$modal.msgSuccess("删除成功");
  266. }).catch(() => { });
  267. },
  268. /** 导出按钮操作 */
  269. handleExport() {
  270. this.download('system/check/export', {
  271. ...this.queryParams
  272. }, `check_${new Date().getTime()}.xlsx`)
  273. }
  274. }
  275. };
  276. </script>