index.vue 9.5 KB

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