index.vue 13 KB

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