index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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="域名" prop="domainName">
  5. <el-input
  6. v-model="queryParams.domainName"
  7. placeholder="请输入域名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态" prop="status">
  14. <el-select style="width: 220px" v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  15. <el-option
  16. v-for="dict in statusOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="el-icon-plus"
  34. size="mini"
  35. @click="handleAdd"
  36. v-hasPermi="['course:courseDomainName:add']"
  37. >新增</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="warning"
  42. plain
  43. icon="el-icon-download"
  44. size="mini"
  45. :loading="exportLoading"
  46. @click="handleExport"
  47. v-hasPermi="['course:courseDomainName:export']"
  48. >导出</el-button>
  49. </el-col>
  50. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  51. </el-row>
  52. <el-table border v-loading="loading" :data="courseDomainNameList" @selection-change="handleSelectionChange">
  53. <el-table-column type="selection" width="55" align="center" />
  54. <el-table-column label="ID" width="70" align="center" prop="id" />
  55. <el-table-column label="域名" align="center" prop="domainName" />
  56. <el-table-column label="状态" align="center" prop="status" >
  57. <template slot-scope="scope">
  58. <el-tag prop="status" v-for="(item, index) in statusOptions" :type="scope.row.status==1?'success':'danger'" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="创建时间" align="center" prop="createTime" />
  62. <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
  63. <!-- <template slot-scope="scope">-->
  64. <!-- <el-button-->
  65. <!-- size="mini"-->
  66. <!-- type="text"-->
  67. <!-- icon="el-icon-edit"-->
  68. <!-- @click="handleUpdate(scope.row)"-->
  69. <!-- v-hasPermi="['course:courseDomainName:edit']"-->
  70. <!-- >修改</el-button>-->
  71. <!-- <el-button-->
  72. <!-- size="mini"-->
  73. <!-- type="text"-->
  74. <!-- icon="el-icon-delete"-->
  75. <!-- @click="handleDelete(scope.row)"-->
  76. <!-- v-hasPermi="['course:courseDomainName:remove']"-->
  77. <!-- >删除</el-button>-->
  78. <!-- </template>-->
  79. <!-- </el-table-column>-->
  80. </el-table>
  81. <pagination
  82. v-show="total>0"
  83. :total="total"
  84. :page.sync="queryParams.pageNum"
  85. :limit.sync="queryParams.pageSize"
  86. @pagination="getList"
  87. />
  88. <!-- 添加或修改课程短链域名对话框 -->
  89. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  90. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  91. <el-form-item label="域名" prop="domainName">
  92. <div style="display: flex; align-items: center;">
  93. <el-input v-model="form.domainName" placeholder="请输入域名" style="width: 200px;" />
  94. </div>
  95. </el-form-item>
  96. <el-form-item label="状态" prop="status">
  97. <el-radio-group v-model="form.status">
  98. <el-radio v-for="dict in statusOptions" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
  99. </el-radio-group>
  100. </el-form-item>
  101. </el-form>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button type="primary" @click="submitForm">确 定</el-button>
  104. <el-button @click="cancel">取 消</el-button>
  105. </div>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. import { listCourseDomainName, getCourseDomainName, delCourseDomainName, addCourseDomainName, updateCourseDomainName, exportCourseDomainName } from "@/api/course/courseDomainName";
  111. export default {
  112. name: "CourseDomainName",
  113. data() {
  114. return {
  115. statusOptions:[],
  116. // 遮罩层
  117. loading: true,
  118. // 导出遮罩层
  119. exportLoading: false,
  120. // 选中数组
  121. ids: [],
  122. // 非单个禁用
  123. single: true,
  124. // 非多个禁用
  125. multiple: true,
  126. // 显示搜索条件
  127. showSearch: true,
  128. // 总条数
  129. total: 0,
  130. // 课程短链域名表格数据
  131. courseDomainNameList: [],
  132. // 弹出层标题
  133. title: "",
  134. // 是否显示弹出层
  135. open: false,
  136. // 查询参数
  137. queryParams: {
  138. pageNum: 1,
  139. pageSize: 10,
  140. domainName: null,
  141. status: null,
  142. },
  143. // 表单参数
  144. form: {},
  145. // 表单校验
  146. rules: {
  147. }
  148. };
  149. },
  150. created() {
  151. this.getList();
  152. this.getDicts("sys_company_status").then((response) => {
  153. this.statusOptions = response.data;
  154. });
  155. },
  156. methods: {
  157. /** 查询课程短链域名列表 */
  158. getList() {
  159. this.loading = true;
  160. listCourseDomainName(this.queryParams).then(response => {
  161. this.courseDomainNameList = response.rows;
  162. this.total = response.total;
  163. this.loading = false;
  164. });
  165. },
  166. // 取消按钮
  167. cancel() {
  168. this.open = false;
  169. this.reset();
  170. },
  171. // 表单重置
  172. reset() {
  173. this.form = {
  174. id: null,
  175. domainName: null,
  176. status: "1",
  177. createTime: null,
  178. updateTime: null
  179. };
  180. this.resetForm("form");
  181. },
  182. /** 搜索按钮操作 */
  183. handleQuery() {
  184. this.queryParams.pageNum = 1;
  185. this.getList();
  186. },
  187. /** 重置按钮操作 */
  188. resetQuery() {
  189. this.resetForm("queryForm");
  190. this.handleQuery();
  191. },
  192. // 多选框选中数据
  193. handleSelectionChange(selection) {
  194. this.ids = selection.map(item => item.id)
  195. this.single = selection.length!==1
  196. this.multiple = !selection.length
  197. },
  198. /** 新增按钮操作 */
  199. handleAdd() {
  200. this.reset();
  201. this.open = true;
  202. this.title = "添加课程短链域名";
  203. },
  204. /** 修改按钮操作 */
  205. handleUpdate(row) {
  206. this.reset();
  207. const id = row.id || this.ids
  208. getCourseDomainName(id).then(response => {
  209. this.form = response.data;
  210. this.open = true;
  211. this.title = "修改课程短链域名";
  212. });
  213. },
  214. /** 提交按钮 */
  215. submitForm() {
  216. this.$refs["form"].validate(valid => {
  217. if (valid) {
  218. if (this.form.id != null) {
  219. updateCourseDomainName(this.form).then(response => {
  220. this.msgSuccess("修改成功");
  221. this.open = false;
  222. this.getList();
  223. });
  224. } else {
  225. addCourseDomainName(this.form).then(response => {
  226. this.msgSuccess("新增成功");
  227. this.open = false;
  228. this.getList();
  229. });
  230. }
  231. }
  232. });
  233. },
  234. /** 删除按钮操作 */
  235. handleDelete(row) {
  236. const ids = row.id || this.ids;
  237. this.$confirm('是否确认删除课程短链域名编号为"' + ids + '"的数据项?', "警告", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning"
  241. }).then(function() {
  242. return delCourseDomainName(ids);
  243. }).then(() => {
  244. this.getList();
  245. this.msgSuccess("删除成功");
  246. }).catch(() => {});
  247. },
  248. /** 导出按钮操作 */
  249. handleExport() {
  250. const queryParams = this.queryParams;
  251. this.$confirm('是否确认导出所有课程短链域名数据项?', "警告", {
  252. confirmButtonText: "确定",
  253. cancelButtonText: "取消",
  254. type: "warning"
  255. }).then(() => {
  256. this.exportLoading = true;
  257. return exportCourseDomainName(queryParams);
  258. }).then(response => {
  259. this.download(response.msg);
  260. this.exportLoading = false;
  261. }).catch(() => {});
  262. }
  263. }
  264. };
  265. </script>