index.vue 13 KB

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