index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="区域名称" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入区域名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="机构类型" prop="orgType">
  13. <el-select
  14. v-model="queryParams.orgType"
  15. placeholder="请选择机构类型"
  16. clearable
  17. style="width: 240px"
  18. >
  19. <el-option
  20. v-for="dict in dict.type.sys_org_type"
  21. :key="dict.value"
  22. :label="dict.label"
  23. :value="dict.value"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. plain
  37. icon="el-icon-plus"
  38. size="mini"
  39. @click="handleAdd"
  40. v-hasPermi="['system:area:add']"
  41. >新增</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button
  45. type="success"
  46. plain
  47. icon="el-icon-edit"
  48. size="mini"
  49. :disabled="single"
  50. @click="handleUpdate"
  51. v-hasPermi="['system:area:edit']"
  52. >修改</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="danger"
  57. plain
  58. icon="el-icon-delete"
  59. size="mini"
  60. :disabled="multiple"
  61. @click="handleDelete"
  62. v-hasPermi="['system:area:remove']"
  63. >删除</el-button>
  64. </el-col>
  65. <!-- <el-col :span="1.5">
  66. <el-button
  67. type="warning"
  68. plain
  69. icon="el-icon-download"
  70. size="mini"
  71. @click="handleExport"
  72. v-hasPermi="['system:area:export']"
  73. >导出</el-button>
  74. </el-col> -->
  75. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  76. </el-row>
  77. <el-table v-loading="loading" :data="areaList" @selection-change="handleSelectionChange">
  78. <el-table-column type="selection" width="55" align="center" />
  79. <el-table-column label="区域名称" align="center" prop="name" />
  80. <el-table-column label="机构类型" align="center" prop="orgType" />
  81. <el-table-column label="更新人" align="center" prop="updateBy" />
  82. <el-table-column label="创建时间" align="center" prop="createTime" />
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-edit"
  89. @click="handleUpdate(scope.row)"
  90. v-hasPermi="['system:area:edit']"
  91. >修改</el-button>
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-delete"
  96. @click="handleDelete(scope.row)"
  97. v-hasPermi="['system:area:remove']"
  98. >删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <pagination
  103. v-show="total>0"
  104. :total="total"
  105. :page.sync="queryParams.pageNum"
  106. :limit.sync="queryParams.pageSize"
  107. @pagination="getList"
  108. />
  109. <!-- 添加或修改【请填写功能名称】对话框 -->
  110. <DialogCom :title="title" :visible.sync="open" width="500px" append-to-body>
  111. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  112. <el-form-item label="区域名称" prop="name">
  113. <el-input v-model="form.name" placeholder="请输入区域名称" />
  114. </el-form-item>
  115. <el-form-item label="机构类型" prop="orgType">
  116. <el-select v-model="form.orgType" placeholder="请选择机构类型">
  117. <el-option
  118. v-for="dict in dict.type.sys_org_type"
  119. :key="dict.value"
  120. :label="dict.label"
  121. :value="`${dict.value}`"
  122. ></el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button type="primary" @click="submitForm">确 定</el-button>
  128. <el-button @click="cancel">取 消</el-button>
  129. </div>
  130. </DialogCom>
  131. </div>
  132. </template>
  133. <script>
  134. import { listArea, getArea, delArea, addArea, updateArea } from "@/api/system/area";
  135. export default {
  136. name: "Area",
  137. dicts:['sys_org_type'],
  138. data() {
  139. return {
  140. // 遮罩层
  141. loading: true,
  142. // 选中数组
  143. ids: [],
  144. names:[],
  145. // 非单个禁用
  146. single: true,
  147. // 非多个禁用
  148. multiple: true,
  149. // 显示搜索条件
  150. showSearch: true,
  151. // 总条数
  152. total: 0,
  153. // 【请填写功能名称】表格数据
  154. areaList: [],
  155. // 弹出层标题
  156. title: "",
  157. // 是否显示弹出层
  158. open: false,
  159. // 查询参数
  160. queryParams: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. name: null,
  164. updateId: null,
  165. orgType: null
  166. },
  167. // 表单参数
  168. form: {},
  169. // 表单校验
  170. rules: {
  171. name: [
  172. { required: true, message: '请输入区域名称', trigger: 'blur' },
  173. ],
  174. orgType: [
  175. { required: true, message: '请选择机构类型', trigger: 'change' },
  176. ],
  177. }
  178. };
  179. },
  180. created() {
  181. this.getList();
  182. },
  183. methods: {
  184. /** 查询【请填写功能名称】列表 */
  185. getList() {
  186. this.loading = true;
  187. listArea(this.queryParams).then(response => {
  188. this.areaList = response.rows;
  189. this.total = response.total;
  190. this.loading = false;
  191. });
  192. },
  193. // 取消按钮
  194. cancel() {
  195. this.open = false;
  196. this.reset();
  197. },
  198. // 表单重置
  199. reset() {
  200. this.form = {
  201. id: null,
  202. name: null,
  203. createTime: null,
  204. updateBy: null,
  205. updateTime: null,
  206. updateId: null,
  207. delFlag: null,
  208. orgType: null
  209. };
  210. this.resetForm("form");
  211. },
  212. /** 搜索按钮操作 */
  213. handleQuery() {
  214. this.queryParams.pageNum = 1;
  215. this.getList();
  216. },
  217. /** 重置按钮操作 */
  218. resetQuery() {
  219. this.resetForm("queryForm");
  220. this.handleQuery();
  221. },
  222. // 多选框选中数据
  223. handleSelectionChange(selection) {
  224. this.ids = selection.map(item => item.id)
  225. this.names=selection.map(item => item.name)
  226. this.single = selection.length!==1
  227. this.multiple = !selection.length
  228. },
  229. /** 新增按钮操作 */
  230. handleAdd() {
  231. this.reset();
  232. this.open = true;
  233. this.title = "添加";
  234. },
  235. /** 修改按钮操作 */
  236. handleUpdate(row) {
  237. this.reset();
  238. const id = row.id || this.ids
  239. getArea(id).then(response => {
  240. this.form = response.data;
  241. this.open = true;
  242. this.title = "修改";
  243. });
  244. },
  245. /** 提交按钮 */
  246. submitForm() {
  247. this.$refs["form"].validate(valid => {
  248. if (valid) {
  249. if (this.form.id != null) {
  250. updateArea(this.form).then(response => {
  251. this.$modal.msgSuccess("修改成功");
  252. this.open = false;
  253. this.getList();
  254. });
  255. } else {
  256. addArea(this.form).then(response => {
  257. this.$modal.msgSuccess("新增成功");
  258. this.open = false;
  259. this.getList();
  260. });
  261. }
  262. }
  263. });
  264. },
  265. /** 删除按钮操作 */
  266. handleDelete(row) {
  267. const ids = row.id || this.ids;
  268. const names=row.name || this.names;
  269. this.$modal.confirm('是否确认删除区域名称为"' + names + '"的数据项?').then(function() {
  270. return delArea(ids);
  271. }).then(() => {
  272. this.getList();
  273. this.$modal.msgSuccess("删除成功");
  274. }).catch(() => {});
  275. },
  276. /** 导出按钮操作 */
  277. handleExport() {
  278. this.download('system/area/export', {
  279. ...this.queryParams
  280. }, `area_${new Date().getTime()}.xlsx`)
  281. }
  282. }
  283. };
  284. </script>