index.vue 11 KB

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