index.vue 13 KB

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