index.vue 7.9 KB

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