瀚海黎明企业官网后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
7.6 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 weeks ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  7. <el-form-item label="名称" prop="title">
  8. <el-input v-model="queryParams.title" placeholder="请输入名称" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  12. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </el-card>
  16. </div>
  17. </transition>
  18. <el-card shadow="never">
  19. <template #header>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['officialWebsite:caseCategory:add']">新增</el-button>
  23. </el-col>
  24. <el-col :span="1.5">
  25. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['officialWebsite:caseCategory:edit']">修改</el-button>
  26. </el-col>
  27. <el-col :span="1.5">
  28. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['officialWebsite:caseCategory:remove']">删除</el-button>
  29. </el-col>
  30. <el-col :span="1.5">
  31. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['officialWebsite:caseCategory:export']">导出</el-button>
  32. </el-col>
  33. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  34. </el-row>
  35. </template>
  36. <el-table v-loading="loading" :data="caseCategoryList" @selection-change="handleSelectionChange">
  37. <el-table-column type="selection" width="55" align="center" />
  38. <el-table-column label="编号" align="center" prop="id" v-if="true" />
  39. <el-table-column label="名称" align="center" prop="title" />
  40. <el-table-column label="排序" align="center" prop="sort" />
  41. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  42. <template #default="scope">
  43. <el-tooltip content="修改" placement="top">
  44. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['officialWebsite:caseCategory:edit']"></el-button>
  45. </el-tooltip>
  46. <el-tooltip content="删除" placement="top">
  47. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['officialWebsite:caseCategory:remove']"></el-button>
  48. </el-tooltip>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <!-- <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> -->
  53. </el-card>
  54. <!-- 添加或修改OW案例分类对话框 -->
  55. <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
  56. <el-form ref="caseCategoryFormRef" :model="form" :rules="rules" label-width="80px">
  57. <el-form-item label="名称" prop="title">
  58. <el-input v-model="form.title" placeholder="请输入名称" />
  59. </el-form-item>
  60. <el-form-item label="显示排序" prop="sort">
  61. <el-input-number v-model="form.sort" controls-position="right" :min="0" />
  62. </el-form-item>
  63. </el-form>
  64. <template #footer>
  65. <div class="dialog-footer">
  66. <el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
  67. <el-button @click="cancel"> </el-button>
  68. </div>
  69. </template>
  70. </el-dialog>
  71. </div>
  72. </template>
  73. <script setup name="CaseCategory" lang="ts">
  74. import { listCaseCategory, getCaseCategory, delCaseCategory, addCaseCategory, updateCaseCategory } from '@/api/officialWebsite/caseCategory';
  75. import { CaseCategoryVO, CaseCategoryQuery, CaseCategoryForm } from '@/api/officialWebsite/caseCategory/types';
  76. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  77. const caseCategoryList = ref<CaseCategoryVO[]>([]);
  78. const buttonLoading = ref(false);
  79. const loading = ref(true);
  80. const showSearch = ref(true);
  81. const ids = ref<Array<string | number>>([]);
  82. const single = ref(true);
  83. const multiple = ref(true);
  84. const total = ref(0);
  85. const queryFormRef = ref<ElFormInstance>();
  86. const caseCategoryFormRef = ref<ElFormInstance>();
  87. const dialog = reactive<DialogOption>({
  88. visible: false,
  89. title: ''
  90. });
  91. const initFormData: CaseCategoryForm = {
  92. id: undefined,
  93. title: undefined,
  94. sort: 0,
  95. }
  96. const data = reactive<PageData<CaseCategoryForm, CaseCategoryQuery>>({
  97. form: {...initFormData},
  98. queryParams: {
  99. pageNum: 1,
  100. pageSize: 10,
  101. title: undefined,
  102. params: {
  103. }
  104. },
  105. rules: {
  106. id: [
  107. { required: true, message: "编号不能为空", trigger: "blur" }
  108. ],
  109. title: [
  110. { required: true, message: "名称不能为空", trigger: "blur" }
  111. ],
  112. sort: [
  113. { required: true, message: "排序不能为空", trigger: "blur" }
  114. ],
  115. }
  116. });
  117. const { queryParams, form, rules } = toRefs(data);
  118. /** 查询OW案例分类列表 */
  119. const getList = async () => {
  120. loading.value = true;
  121. const res = await listCaseCategory(queryParams.value);
  122. caseCategoryList.value = res.data;
  123. total.value = res.total;
  124. loading.value = false;
  125. }
  126. /** 取消按钮 */
  127. const cancel = () => {
  128. reset();
  129. dialog.visible = false;
  130. }
  131. /** 表单重置 */
  132. const reset = () => {
  133. form.value = {...initFormData};
  134. caseCategoryFormRef.value?.resetFields();
  135. }
  136. /** 搜索按钮操作 */
  137. const handleQuery = () => {
  138. queryParams.value.pageNum = 1;
  139. getList();
  140. }
  141. /** 重置按钮操作 */
  142. const resetQuery = () => {
  143. queryFormRef.value?.resetFields();
  144. handleQuery();
  145. }
  146. /** 多选框选中数据 */
  147. const handleSelectionChange = (selection: CaseCategoryVO[]) => {
  148. ids.value = selection.map(item => item.id);
  149. single.value = selection.length != 1;
  150. multiple.value = !selection.length;
  151. }
  152. /** 新增按钮操作 */
  153. const handleAdd = () => {
  154. reset();
  155. dialog.visible = true;
  156. dialog.title = "添加案例分类";
  157. }
  158. /** 修改按钮操作 */
  159. const handleUpdate = async (row?: CaseCategoryVO) => {
  160. reset();
  161. const _id = row?.id || ids.value[0]
  162. const res = await getCaseCategory(_id);
  163. Object.assign(form.value, res.data);
  164. dialog.visible = true;
  165. dialog.title = "修改案例分类";
  166. }
  167. /** 提交按钮 */
  168. const submitForm = () => {
  169. caseCategoryFormRef.value?.validate(async (valid: boolean) => {
  170. if (valid) {
  171. buttonLoading.value = true;
  172. if (form.value.id) {
  173. await updateCaseCategory(form.value).finally(() => buttonLoading.value = false);
  174. } else {
  175. await addCaseCategory(form.value).finally(() => buttonLoading.value = false);
  176. }
  177. proxy?.$modal.msgSuccess("操作成功");
  178. dialog.visible = false;
  179. await getList();
  180. }
  181. });
  182. }
  183. /** 删除按钮操作 */
  184. const handleDelete = async (row?: CaseCategoryVO) => {
  185. const _ids = row?.id || ids.value;
  186. await proxy?.$modal.confirm('是否确认删除案例分类编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
  187. await delCaseCategory(_ids);
  188. proxy?.$modal.msgSuccess("删除成功");
  189. await getList();
  190. }
  191. /** 导出按钮操作 */
  192. const handleExport = () => {
  193. proxy?.download('officialWebsite/caseCategory/export', {
  194. ...queryParams.value
  195. }, `caseCategory_${new Date().getTime()}.xlsx`)
  196. }
  197. onMounted(() => {
  198. getList();
  199. });
  200. </script>