index.vue 12 KB

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