index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-row :gutter="10">
  5. <el-col :span="6">
  6. <el-form-item label="昵称" prop="nickName">
  7. <el-input
  8. v-model="queryParams.nickName"
  9. placeholder="请输入昵称"
  10. clearable
  11. size="small"
  12. @keyup.enter.native="handleQuery"
  13. />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="6">
  17. <el-form-item label="密码" prop="password">
  18. <el-input
  19. v-model="queryParams.password"
  20. placeholder="请输入密码"
  21. clearable
  22. size="small"
  23. @keyup.enter.native="handleQuery"
  24. />
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-form-item label="手机号" prop="mobile">
  29. <el-input
  30. v-model="queryParams.mobile"
  31. placeholder="请输入手机号"
  32. clearable
  33. size="small"
  34. @keyup.enter.native="handleQuery"
  35. />
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="6">
  39. <el-form-item label="微信OPENID" prop="openId">
  40. <el-input
  41. v-model="queryParams.openId"
  42. placeholder="请输入微信OPENID"
  43. clearable
  44. size="small"
  45. @keyup.enter.native="handleQuery"
  46. />
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <el-row :gutter="10">
  51. <el-col :span="6">
  52. <el-form-item label="身份证反面" prop="idCardBackUrl">
  53. <el-input
  54. v-model="queryParams.idCardBackUrl"
  55. placeholder="请输入身份证反面"
  56. clearable
  57. size="small"
  58. @keyup.enter.native="handleQuery"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="6">
  63. <el-form-item label="身份证正面" prop="idCardFrontUrl">
  64. <el-input
  65. v-model="queryParams.idCardFrontUrl"
  66. placeholder="请输入身份证正面"
  67. clearable
  68. size="small"
  69. @keyup.enter.native="handleQuery"
  70. />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6">
  74. <el-form-item label="状态" prop="status">
  75. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  76. <!-- <el-option label="请选择字典生成" value="" />-->
  77. <el-option
  78. v-for="dict in statusOptions"
  79. :key="dict.dictValue"
  80. :label="dict.dictLabel"
  81. :value="dict.dictValue"
  82. ></el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="6">
  87. <el-form-item>
  88. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  89. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. </el-form>
  94. <el-row :gutter="10" class="mb8">
  95. <el-col :span="1.5">
  96. <el-button
  97. type="primary"
  98. plain
  99. icon="el-icon-plus"
  100. size="mini"
  101. @click="handleAdd"
  102. v-hasPermi="['live:liveAnchor:add']"
  103. >新增</el-button>
  104. </el-col>
  105. <el-col :span="1.5">
  106. <el-button
  107. type="success"
  108. plain
  109. icon="el-icon-edit"
  110. size="mini"
  111. :disabled="single"
  112. @click="handleUpdate"
  113. v-hasPermi="['live:liveAnchor:edit']"
  114. >修改</el-button>
  115. </el-col>
  116. <el-col :span="1.5">
  117. <el-button
  118. type="danger"
  119. plain
  120. icon="el-icon-delete"
  121. size="mini"
  122. :disabled="multiple"
  123. @click="handleDelete"
  124. v-hasPermi="['live:liveAnchor:remove']"
  125. >删除</el-button>
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-button
  129. type="warning"
  130. plain
  131. icon="el-icon-download"
  132. size="mini"
  133. :loading="exportLoading"
  134. @click="handleExport"
  135. v-hasPermi="['live:liveAnchor:export']"
  136. >导出</el-button>
  137. </el-col>
  138. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  139. </el-row>
  140. <el-table border v-loading="loading" :data="liveAnchorList" @selection-change="handleSelectionChange">
  141. <el-table-column type="selection" width="55" align="center" />
  142. <el-table-column label="ID" align="center" prop="anchorId" />
  143. <el-table-column label="昵称" align="center" prop="nickName" />
  144. <el-table-column label="密码" align="center" prop="password" />
  145. <el-table-column label="手机号" align="center" prop="mobile" />
  146. <el-table-column label="微信OPENID" align="center" prop="openId" />
  147. <el-table-column label="身份证反面" align="center" prop="idCardBackUrl" />
  148. <el-table-column label="身份证正面" align="center" prop="idCardFrontUrl" />
  149. <el-table-column label="状态" align="center" prop="status" :formatter="anchorStatusFormatter"/>
  150. <el-table-column label="备注" align="center" prop="remark" />
  151. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  152. <template slot-scope="scope">
  153. <el-button
  154. size="mini"
  155. type="text"
  156. icon="el-icon-edit"
  157. @click="handleUpdate(scope.row)"
  158. v-hasPermi="['live:liveAnchor:edit']"
  159. >修改</el-button>
  160. <el-button
  161. size="mini"
  162. type="text"
  163. icon="el-icon-delete"
  164. @click="handleDelete(scope.row)"
  165. v-hasPermi="['live:liveAnchor:remove']"
  166. >删除</el-button>
  167. </template>
  168. </el-table-column>
  169. </el-table>
  170. <pagination
  171. v-show="total>0"
  172. :total="total"
  173. :page.sync="queryParams.pageNum"
  174. :limit.sync="queryParams.pageSize"
  175. @pagination="getList"
  176. />
  177. <!-- 添加或修改主播对话框 -->
  178. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  179. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  180. <el-form-item label="昵称" prop="nickName">
  181. <el-input v-model="form.nickName" placeholder="请输入昵称" />
  182. </el-form-item>
  183. <el-form-item label="密码" prop="password">
  184. <el-input v-model="form.password" placeholder="请输入密码" />
  185. </el-form-item>
  186. <el-form-item label="手机号" prop="mobile">
  187. <el-input v-model="form.mobile" placeholder="请输入手机号" />
  188. </el-form-item>
  189. <el-form-item label="微信OPENID" prop="openId">
  190. <el-input v-model="form.openId" placeholder="请输入微信OPENID" />
  191. </el-form-item>
  192. <el-form-item label="身份证反面" prop="idCardBackUrl">
  193. <el-input v-model="form.idCardBackUrl" placeholder="请输入身份证反面" />
  194. </el-form-item>
  195. <el-form-item label="身份证正面" prop="idCardFrontUrl">
  196. <el-input v-model="form.idCardFrontUrl" placeholder="请输入身份证正面" />
  197. </el-form-item>
  198. <el-form-item label="状态">
  199. <el-radio-group v-model="form.status">
  200. <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
  201. </el-radio-group>
  202. </el-form-item>
  203. <el-form-item label="备注" prop="remark">
  204. <el-input v-model="form.remark" placeholder="请输入备注" />
  205. </el-form-item>
  206. </el-form>
  207. <div slot="footer" class="dialog-footer">
  208. <el-button type="primary" @click="submitForm">确 定</el-button>
  209. <el-button @click="cancel">取 消</el-button>
  210. </div>
  211. </el-dialog>
  212. </div>
  213. </template>
  214. <script>
  215. import { listLiveAnchor, getLiveAnchor, delLiveAnchor, addLiveAnchor, updateLiveAnchor, exportLiveAnchor } from "@/api/live/liveAnchor";
  216. export default {
  217. name: "LiveAnchor",
  218. data() {
  219. return {
  220. //字典
  221. statusOptions: [],
  222. // 遮罩层
  223. loading: true,
  224. // 导出遮罩层
  225. exportLoading: false,
  226. // 选中数组
  227. ids: [],
  228. // 非单个禁用
  229. single: true,
  230. // 非多个禁用
  231. multiple: true,
  232. // 显示搜索条件
  233. showSearch: true,
  234. // 总条数
  235. total: 0,
  236. // 主播表格数据
  237. liveAnchorList: [],
  238. // 弹出层标题
  239. title: "",
  240. // 是否显示弹出层
  241. open: false,
  242. // 查询参数
  243. queryParams: {
  244. pageNum: 1,
  245. pageSize: 10,
  246. nickName: null,
  247. password: null,
  248. mobile: null,
  249. openId: null,
  250. idCardBackUrl: null,
  251. idCardFrontUrl: null,
  252. status: null,
  253. },
  254. // 表单参数
  255. form: {},
  256. // 表单校验
  257. rules: {
  258. }
  259. };
  260. },
  261. created() {
  262. this.getList();
  263. this.getDicts("sys_live_anchor_status").then(response => {
  264. this.statusOptions = response.data;
  265. });
  266. },
  267. methods: {
  268. /** 查询主播列表 */
  269. getList() {
  270. this.loading = true;
  271. listLiveAnchor(this.queryParams).then(response => {
  272. this.liveAnchorList = response.rows;
  273. this.total = response.total;
  274. this.loading = false;
  275. });
  276. },
  277. // 取消按钮
  278. cancel() {
  279. this.open = false;
  280. this.reset();
  281. },
  282. // 表单重置
  283. reset() {
  284. this.form = {
  285. anchorId: null,
  286. nickName: null,
  287. password: null,
  288. mobile: null,
  289. openId: null,
  290. idCardBackUrl: null,
  291. idCardFrontUrl: null,
  292. status: 0,
  293. createTime: null,
  294. createBy: null,
  295. updateBy: null,
  296. updateTime: null,
  297. remark: null
  298. };
  299. this.resetForm("form");
  300. },
  301. /** 搜索按钮操作 */
  302. handleQuery() {
  303. this.queryParams.pageNum = 1;
  304. this.getList();
  305. },
  306. /** 重置按钮操作 */
  307. resetQuery() {
  308. this.resetForm("queryForm");
  309. this.handleQuery();
  310. },
  311. // 多选框选中数据
  312. handleSelectionChange(selection) {
  313. this.ids = selection.map(item => item.anchorId)
  314. this.single = selection.length!==1
  315. this.multiple = !selection.length
  316. },
  317. /** 新增按钮操作 */
  318. handleAdd() {
  319. this.reset();
  320. this.open = true;
  321. this.title = "添加主播";
  322. },
  323. /** 修改按钮操作 */
  324. handleUpdate(row) {
  325. this.reset();
  326. const anchorId = row.anchorId || this.ids
  327. getLiveAnchor(anchorId).then(response => {
  328. this.form = response.data;
  329. this.open = true;
  330. this.title = "修改主播";
  331. });
  332. },
  333. /** 提交按钮 */
  334. submitForm() {
  335. this.$refs["form"].validate(valid => {
  336. if (valid) {
  337. if (this.form.anchorId != null) {
  338. updateLiveAnchor(this.form).then(response => {
  339. this.msgSuccess("修改成功");
  340. this.open = false;
  341. this.getList();
  342. });
  343. } else {
  344. addLiveAnchor(this.form).then(response => {
  345. this.msgSuccess("新增成功");
  346. this.open = false;
  347. this.getList();
  348. });
  349. }
  350. }
  351. });
  352. },
  353. /** 删除按钮操作 */
  354. handleDelete(row) {
  355. const anchorIds = row.anchorId || this.ids;
  356. this.$confirm('是否确认删除主播编号为"' + anchorIds + '"的数据项?', "警告", {
  357. confirmButtonText: "确定",
  358. cancelButtonText: "取消",
  359. type: "warning"
  360. }).then(function() {
  361. return delLiveAnchor(anchorIds);
  362. }).then(() => {
  363. this.getList();
  364. this.msgSuccess("删除成功");
  365. }).catch(() => {});
  366. },
  367. /** 导出按钮操作 */
  368. handleExport() {
  369. const queryParams = this.queryParams;
  370. this.$confirm('是否确认导出所有主播数据项?', "警告", {
  371. confirmButtonText: "确定",
  372. cancelButtonText: "取消",
  373. type: "warning"
  374. }).then(() => {
  375. this.exportLoading = true;
  376. return exportLiveAnchor(queryParams);
  377. }).then(response => {
  378. this.download(response.msg);
  379. this.exportLoading = false;
  380. }).catch(() => {});
  381. }
  382. }
  383. };
  384. </script>
  385. <style >
  386. .el-form-item__label {
  387. width: 120px !important;
  388. }
  389. .el-input {
  390. width: 80% !important;
  391. }
  392. </style>