index.vue 7.9 KB

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