index.vue 9.8 KB

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