index.vue 12 KB

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