fix:模板页面(未完成)

This commit is contained in:
shijing 2025-05-06 10:56:44 +08:00
parent 9c9f4a3180
commit 39b88135a1
2 changed files with 206 additions and 0 deletions

View File

@ -45,4 +45,46 @@ export default {
}
},
},
labeltemplate:{
list: {
name: "列表",
req: async function(data){
return await http.get(
`${config.API_URL}/cm/labeltemplate/`,
data
);
}
},
item: {
name: "详情",
req: async function(id){
return await http.get(
`${config.API_URL}/cm/labeltemplate/${id}/`
);
}
},
update: {
name: "更新",
req: async function(id, data){
return await http.put(
`${config.API_URL}/cm/labeltemplate/${id}/`,
data);
}
},
create: {
name: "新增",
req: async function(data){
return await http.post(
`${config.API_URL}/cm/labeltemplate/`,
data);
}
},
delete: {
name: "删除",
req: async function(id){
return await http.delete(
`${config.API_URL}/cm/labeltemplate/${id}/`);
}
},
}
}

View File

@ -0,0 +1,164 @@
<template>
<el-container>
<el-header>
<div class="left-panel">
<el-button type="primary" icon="el-icon-plus" @click="labelTemplateAdd"></el-button>
</div>
<div class="right-panel">
<el-input v-model="query.search" placeholder="模板名称" clearable @keyup.enter="handleQuery"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id" @selection-change="selectionChange" hidePagination>
<el-table-column label="#" type="index" width="50"></el-table-column>
<el-table-column label="模板名称" prop="name" min-width="100"></el-table-column>
<el-table-column label="创建时间" prop="description" min-width="150"></el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="140">
<template #default="scope">
<el-button link size="small" @click="labelTemplateEdit(scope.row)" type="primary">编辑</el-button>
<el-divider direction="vertical"></el-divider>
<el-popconfirm title="确定删除吗?" @confirm="labelTemplateDel(scope.row)">
<template #reference>
<el-button link size="small" type="danger">删除</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
<el-dialog :title="titleMap[type]" v-model="limitedVisible" :width="1000">
<el-form :model="addForm" :rules="rules" ref="addForm" label-width="100px" label-position="left">
<el-form-item label="模板名称" prop="name" auto>
<el-input v-model="addForm.name" clearable></el-input>
</el-form-item>
<el-form-item label="模板代码" prop="commands" auto>
<el-input v-model="addForm.commands" clearable :rows="9" type="textarea"></el-input>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="limitedVisible=false" > </el-button>
<el-button v-if="type!=='show'" type="primary" :loading="isSaving" @click="submitHandle()"> </el-button>
</template>
</el-dialog>
</template>
<script>
const defaultForm = {
id:"",
name: "",
commands: "",
};
export default {
name: 'labeltemplate',
data() {
return {
apiObj: this.$API.cm.labeltemplate.list,
selection: [],
checkList: [],
search: {
keyword: null
},
query: {},
isSaving: false,
limitedVisible : false,
type: "add",
titleMap: {
add: '新增',
edit: '编辑',
show: '查看'
},
//
addForm: defaultForm,
//
rules: {
name: [
{required: true, message: '请输入模板名称'}
],
},
}
},
mounted() {
},
methods: {
//
labelTemplateAdd(){
this.limitedVisible = true;
this.type = "add";
this.$nextTick(()=>{
})
this.addForm = Object.assign({}, defaultForm);
},
submitHandle(){
let that = this;
this.$refs.addForm.validate( (valid) => {
if (valid) {
this.isSaveing = true;
str = [
"SIZE 70 mm,100 mm",
"GAP 7 mm,7 mm",
"CLS",
"REFERENCE 0,0",
'QRCODE 30,400,H,5,A,0,"' +code +'"',
"WINTEXT 240,550,28,90,0,0,Simhei," + row.number,
"PRINT 1",
];
let res;
if(this.type==='add'){
this.$API.system.labelTemplate.create.req(that.addForm).then(res=>{
this.isSaveing = false;
this.limitedVisible = false;
this.$refs.table.refresh();
}).catch(e=>{this.isSaveing = false;})
}else{
this.$API.system.labelTemplate.update.req(that.addForm.id,that.addForm).then(res=>{
this.isSaveing = false;
this.limitedVisible = false;
this.$refs.table.refresh();
}).catch(e=>{this.isSaveing = false;})
}
}
})
},
//
labelTemplateEdit(row){
this.type='edit';
this.addForm.id=row.id;
this.addForm.name=row.name;
this.addForm.commands=row.commands;
this.limitedVisible = true;
},
//
async labelTemplateDel(row){
var id = row.id;
var res = await this.$API.system.labelTemplate.delete.req(id);
if(res.err_msg){
this.$message.error(res.err_msg)
}else{
this.$refs.table.refresh();
this.$message.success("删除成功")
}
},
//
selectionChange(selection){
this.selection = selection;
},
//
handleQuery(){
this.$refs.table.queryData(this.query)
},
//
handleSaveSuccess(data, type){
if(type=='add'){
this.$refs.table.refresh()
}else if(type=='edit'){
this.$refs.table.refresh()
}
}
}
}
</script>