This commit is contained in:
2025-10-06 21:24:03 +08:00
parent 31ca550ead
commit df5e36b24f
3 changed files with 221 additions and 274 deletions

View File

@@ -1,9 +1,9 @@
export default { export default {
height:'auto', height: 'auto',
calcHeight: 30, calcHeight: 30,
tip: false, tip: false,
searchShow: true, searchShow: true,
searchMenuSpan: 6, searchMenuSpan: 10,
border: true, border: true,
index: true, index: true,
viewBtn: true, viewBtn: true,
@@ -11,110 +11,67 @@ export default {
dialogClickModal: false, dialogClickModal: false,
column: [ column: [
{ {
label: "主键", label: 'Id',
prop: "id", prop: 'id',
type: "input", type: 'input',
addDisplay: false, addDisplay: false,
editDisplay: false, editDisplay: false,
viewDisplay: false, viewDisplay: false,
hide: true, hide: true
}, },
{ {
label: "租户ID", label: 'TenantId',
prop: "tenantId", prop: 'tenantId',
type: "input", type: 'input',
addDisplay: false, addDisplay: false,
editDisplay: false, editDisplay: false,
viewDisplay: false, viewDisplay: false,
hide: true, hide: true
}, },
{ {
label: "类型 1:单张,2:组合 3:配件", label: 'Name',
prop: "type", prop: 'name',
type: "radio", type: 'input',
}, },
{ {
label: "产品名称", label: 'PhotoLimit',
prop: "name", prop: 'photoLimit',
type: "input", type: 'number',
min: 1
}, },
{ {
label: "目录图片地址", label: 'Type',
prop: "imageUrl", prop: 'type',
type: "input", type: 'radio',
dicUrl: '/blade-system/dict-biz/dictionary?code=category_type',
props: {
label: 'dictValue',
value: 'dictKey'
},
dataType: 'number',
span: 24
}, },
{ {
label: "照片数量", label: 'Image',
prop: "photoLimit", prop: 'imageUrl',
type: "input", type: 'upload',
listType: 'picture-img',
dataType: 'string',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link'
}
}, },
{ {
label: "形状", label: 'Shape',
prop: "shape", prop: 'shape',
type: "checkbox", type: 'radio',
},
{
label: "创建人",
prop: "createUser",
type: "input",
addDisplay: false, addDisplay: false,
editDisplay: false, editDisplay: false,
viewDisplay: false, viewDisplay: false,
hide: true, hide: true
}, }
{
label: "创建部门",
prop: "createDept",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "创建时间",
prop: "createTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改人",
prop: "updateUser",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "修改时间",
prop: "updateTime",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "状态",
prop: "status",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
{
label: "是否已删除",
prop: "isDeleted",
type: "input",
addDisplay: false,
editDisplay: false,
viewDisplay: false,
hide: true,
},
] ]
} };

View File

@@ -1,11 +1,11 @@
<template> <template>
<basic-container> <basic-container>
<avue-crud :option="option" <avue-crud :option="option"
:table-loading="loading"
:data="data"
v-model:search="search" v-model:search="search"
v-model:page="page" v-model:page="page"
v-model="form" v-model="form"
:table-loading="loading"
:data="data"
:permission="permissionList" :permission="permissionList"
:before-open="beforeOpen" :before-open="beforeOpen"
ref="crud" ref="crud"
@@ -24,12 +24,7 @@
icon="el-icon-delete" icon="el-icon-delete"
plain plain
v-if="permission.category_delete" v-if="permission.category_delete"
@click="handleDelete">删 除 @click="handleDelete">Delete
</el-button>
<el-button type="warning"
plain
icon="el-icon-download"
@click="handleExport">导 出
</el-button> </el-button>
</template> </template>
</avue-crud> </avue-crud>
@@ -37,17 +32,17 @@
</template> </template>
<script> <script>
import {getList, getDetail, add, update, remove} from "@/api/kiosk/category"; import { getList, getDetail, add, update, remove } from '@/api/kiosk/category';
import option from "@/option/kiosk/category"; import option from '@/option/kiosk/category';
import {mapGetters} from "vuex"; import { mapGetters } from 'vuex';
import {exportBlob} from "@/api/common"; import { exportBlob } from '@/api/common';
import {getToken} from '@/utils/auth'; import { getToken } from '@/utils/auth';
import {downloadXls} from "@/utils/util"; import { downloadXls } from '@/utils/util';
import {dateNow} from "@/utils/date"; import { dateNow } from '@/utils/date';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
export default { export default {
data() { data() {
return { return {
form: {}, form: {},
@@ -64,8 +59,23 @@
data: [] data: []
}; };
}, },
watch: {
'form.type'() {
const type = this.form.type;
const photoCol = this.option.column.find(col => col.prop === 'photoLimit');
if (photoCol) {
if (type === 1 || type === 3) {
this.form.photoLimit = 1;
photoCol.disabled = true;
} else {
photoCol.disabled = false;
}
}
}
},
computed: { computed: {
...mapGetters(["permission"]), ...mapGetters(['permission']),
permissionList() { permissionList() {
return { return {
addBtn: this.validData(this.permission.category_add, false), addBtn: this.validData(this.permission.category_add, false),
@@ -79,7 +89,7 @@
this.selectionList.forEach(ele => { this.selectionList.forEach(ele => {
ids.push(ele.id); ids.push(ele.id);
}); });
return ids.join(","); return ids.join(',');
} }
}, },
methods: { methods: {
@@ -87,8 +97,8 @@
add(row).then(() => { add(row).then(() => {
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: 'Success!'
}); });
done(); done();
}, error => { }, error => {
@@ -100,8 +110,8 @@
update(row).then(() => { update(row).then(() => {
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: 'Success!'
}); });
done(); done();
}, error => { }, error => {
@@ -110,10 +120,10 @@
}); });
}, },
rowDel(row) { rowDel(row) {
this.$confirm("确定将选择数据删除?", { this.$confirm('Confirmation for Delete?', {
confirmButtonText: "确定", confirmButtonText: 'Confirm',
cancelButtonText: "取消", cancelButtonText: 'Cancel',
type: "warning" type: 'warning'
}) })
.then(() => { .then(() => {
return remove(row.id); return remove(row.id);
@@ -121,20 +131,20 @@
.then(() => { .then(() => {
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: 'Success!'
}); });
}); });
}, },
handleDelete() { handleDelete() {
if (this.selectionList.length === 0) { if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据"); this.$message.warning('Please select one or more');
return; return;
} }
this.$confirm("确定将选择数据删除?", { this.$confirm('Confirmation for Delete?', {
confirmButtonText: "确定", confirmButtonText: 'Confirm',
cancelButtonText: "取消", cancelButtonText: 'Cancel',
type: "warning" type: 'warning'
}) })
.then(() => { .then(() => {
return remove(this.ids); return remove(this.ids);
@@ -142,32 +152,14 @@
.then(() => { .then(() => {
this.onLoad(this.page); this.onLoad(this.page);
this.$message({ this.$message({
type: "success", type: 'success',
message: "操作成功!" message: 'Success!'
}); });
this.$refs.crud.toggleSelection(); this.$refs.crud.toggleSelection();
}); });
}, },
handleExport() {
let downloadUrl = `/kiosk-category/category/export-category?${this.website.tokenHeader}=${getToken()}`;
const {
} = this.query;
let values = {
};
this.$confirm("是否导出数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
NProgress.start();
exportBlob(downloadUrl, values).then(res => {
downloadXls(res.data, `自助终端产品目录表${dateNow()}.xlsx`);
NProgress.done();
})
});
},
beforeOpen(done, type) { beforeOpen(done, type) {
if (["edit", "view"].includes(type)) { if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => { getDetail(this.form.id).then(res => {
this.form = res.data.data; this.form = res.data.data;
}); });
@@ -191,10 +183,10 @@
this.selectionList = []; this.selectionList = [];
this.$refs.crud.toggleSelection(); this.$refs.crud.toggleSelection();
}, },
currentChange(currentPage){ currentChange(currentPage) {
this.page.currentPage = currentPage; this.page.currentPage = currentPage;
}, },
sizeChange(pageSize){ sizeChange(pageSize) {
this.page.pageSize = pageSize; this.page.pageSize = pageSize;
}, },
refreshChange() { refreshChange() {
@@ -203,11 +195,9 @@
onLoad(page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true;
const { const {} = this.query;
} = this.query;
let values = { let values = {};
};
getList(page.currentPage, page.pageSize, values).then(res => { getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data; const data = res.data.data;
@@ -218,7 +208,7 @@
}); });
} }
} }
}; };
</script> </script>
<style> <style>

View File

@@ -474,7 +474,7 @@ export default {
); );
}, },
rowDel(row) { rowDel(row) {
this.$confirm('Confirmation for DEL?', { this.$confirm('Confirmation for Delete?', {
confirmButtonText: 'Confirm', confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
type: 'warning', type: 'warning',
@@ -510,7 +510,7 @@ export default {
}, },
handleDelete() { handleDelete() {
if (this.selectionList.length === 0) { if (this.selectionList.length === 0) {
this.$message.warning('please select one or more'); this.$message.warning('Please select one or more');
return; return;
} }
this.$confirm('Confirmation for DEL?', { this.$confirm('Confirmation for DEL?', {