This commit is contained in:
张良(004796)
2024-04-23 18:37:21 +08:00
parent 1bf96a502b
commit e798e1b4ea
4 changed files with 338 additions and 2 deletions

View File

@@ -0,0 +1,176 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['xq:pairSuccess:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['xq:pairSuccess:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="pairSuccessList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="成功案例" align="center" prop="picture" >
<template v-slot="scope">
<image-preview :src="scope.row.picture" :height="75" :width="120"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="状态" align="center" prop="enableStatus" >
<template v-slot="scope">
<cai-dict-tag :options="enableStatusList" :value="scope.row.enableStatus"/>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sort"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['xq:pairSuccess:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['xq:pairSuccess:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<pair-success-add-update-dialog v-if="pairSuccessAddOrUpdateDialogVisible" ref="pairSuccessAddOrUpdateDialog" @refreshDataList="getList" />
</div>
</template>
<script>
import { delPairSuccess, listPairSuccess } from '@/api/xq/pairSuccess'
import { enableStatusList } from '@/constant/statusMap'
import PairSuccessAddUpdateDialog from '@/views/xq/pairSuccess/pair-success-add-update-dialog.vue'
import BannerAddUpdateDialog from '@/views/xq/banner/banner-add-update-dialog.vue'
export default {
name: "PairSuccess",
components: { BannerAddUpdateDialog, PairSuccessAddUpdateDialog},
data() {
return {
enableStatusList,
pairSuccessAddOrUpdateDialogVisible: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 成功案例表格数据
pairSuccessList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
},
};
},
created() {
this.getList();
},
methods: {
/** 查询成功案例列表 */
getList() {
this.loading = true;
listPairSuccess(this.queryParams).then(response => {
this.pairSuccessList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.pairSuccessAddOrUpdateDialogVisible = true
this.$nextTick(() => {
this.$refs.pairSuccessAddOrUpdateDialog.init()
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.pairSuccessAddOrUpdateDialogVisible = true
this.$nextTick(() => {
this.$refs.pairSuccessAddOrUpdateDialog.init(row.id)
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除成功案例编号为的数据项?').then(() => {
this.loading = true;
return delPairSuccess(ids);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
}
};
</script>

View File

@@ -0,0 +1,111 @@
<template>
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="成功案例" prop="picture">
<image-upload2 v-model="form.picture"/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" />
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="form.sort" placeholder="请输入排序" />
</el-form-item>
<el-form-item label="状态" prop="enableStatus">
<el-select v-model="form.enableStatus" placeholder="状态" size="small">
<el-option
v-for="dict in enableStatusList"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="open = false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { enableStatusList } from '@/constant/statusMap'
import { addPairSuccess, getPairSuccess, updatePairSuccess } from '@/api/xq/pairSuccess'
export default {
components: {
},
data () {
return {
enableStatusList,
open: false,
title: '',
form:{
id: undefined,
picture: undefined,
sort: undefined,
remark: undefined,
enableStatus: undefined,
},
// 表单校验
rules: {
picture: [
{ required: true, message: "数据不能为空", trigger: "blur" }
],
sort: [
{ required: true, message: "数据不能为空", trigger: "blur" }
],
enableStatus: [
{ required: true, message: "数据不能为空", trigger: "change" }
],
},
buttonLoading: false,
}
},
created() {
},
methods: {
init (id) {
this.form.id = id || undefined;
this.title = (id ? "修改" : "新增") + "成功案例";
this.open = true;
this.$nextTick(() => {
this.$refs['form'].resetFields();
if(this.form.id){
getPairSuccess(id).then(response => {
this.form = response.data;
});
}
})
},
// 表单提交
submitForm () {
this.$refs['form'].validate((valid) => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updatePairSuccess(this.form).then(data => {
this.$modal.msgSuccess("修改成功");
this.$modal.buttonLoading = false;
this.open = false
this.$emit('refreshDataList')
}).finally(() => {
this.buttonLoading = false;
});
}else{
addPairSuccess(this.form).then(data => {
this.$modal.msgSuccess("修改成功");
this.buttonLoading = false;
this.open = false
this.$emit('refreshDataList')
}).finally(() => {
this.buttonLoading = false;
});
}
}
})
},
}
}
</script>