|
@@ -8,7 +8,7 @@
|
|
|
<el-input v-model="sizeHeight" clearable placeholder="请输入尺寸高度"></el-input>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
- <el-col :span="6" class="left">
|
|
|
+ <el-col :span="6" class="left">
|
|
|
<div class="searchBox">
|
|
|
<div class="searchTitle">尺寸宽度</div>
|
|
|
<el-input v-model="sizeWidth" clearable placeholder="请输入尺寸宽度"></el-input>
|
|
@@ -41,7 +41,7 @@
|
|
|
<i class="el-icon-delete"></i>
|
|
|
删除
|
|
|
</div>
|
|
|
- <div class="listEditBtn" @click="goEdit(scope.row.id)">
|
|
|
+ <div class="listEditBtn" @click="goEdit(scope.row.id, scope.row)">
|
|
|
<i class="el-icon-edit-outline"></i>
|
|
|
编辑
|
|
|
</div>
|
|
@@ -119,10 +119,7 @@ export default {
|
|
|
//1.查询条件 end ---------------------------------------->
|
|
|
|
|
|
//2.列表数据 start ---------------------------------------->
|
|
|
- tableData: [
|
|
|
- {"id":1,"height":"1200","width":"300","created_at":"2025-05-23 10:00:00","updated_at":"2025-05-23 10:00:00"},
|
|
|
- {"id":1,"height":"1200","width":"450","created_at":"2025-05-23 10:00:00","updated_at":"2025-05-23 10:00:00"},
|
|
|
- ],
|
|
|
+ tableData: [],
|
|
|
page: 1,
|
|
|
pageSize: 10,
|
|
|
total: 0,
|
|
@@ -147,19 +144,45 @@ export default {
|
|
|
//1.列表和分页相关 start ------------------------------------------------------------>
|
|
|
//1.1 请求数据
|
|
|
getData() {
|
|
|
-
|
|
|
+ this.$store.dispatch('size/getSizeList',{page: this.page,pageSize: this.pageSize}).then(res=> {
|
|
|
+ this.tableData = res.data.row; //给与内容
|
|
|
+ this.total = res.data.count; //给与总条数
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '网络错误,请重试!'
|
|
|
+ });
|
|
|
+ })
|
|
|
},
|
|
|
//1.2 删除
|
|
|
deleteRow(id) {
|
|
|
console.log(id);
|
|
|
let data = new FormData()
|
|
|
data.append('id', id)
|
|
|
- this.$confirm('注意:删除后通栏与组件中无法再选择该尺寸!', '是否确认删除该尺寸?', {
|
|
|
+ this.$confirm('注意:删除后,该条信息及其绑定关系全部删除', '是否确认删除该条信息?', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
}).then(() => {
|
|
|
console.log("当前删除:" + id)
|
|
|
-
|
|
|
+ const data = {
|
|
|
+ id: id, //id
|
|
|
+ }
|
|
|
+ this.$store.dispatch('size/delSize',data).then(res=> {
|
|
|
+ console.log(res);
|
|
|
+ }).then(() => {
|
|
|
+ this.$message({
|
|
|
+ message: '删除成功',
|
|
|
+ type:'success'
|
|
|
+ })
|
|
|
+ this.getData()
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: '删除失败'
|
|
|
+ });
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'warning',
|
|
@@ -180,12 +203,26 @@ export default {
|
|
|
},
|
|
|
// 1.5 搜索
|
|
|
goSearch() {
|
|
|
-
|
|
|
+ const data = {
|
|
|
+ width: this.sizeWidth, //宽度
|
|
|
+ height: this.sizeHeight, //高度
|
|
|
+ page: 1, //页码
|
|
|
+ pageSize: 10, //每页条数
|
|
|
+ }
|
|
|
+ this.$store.dispatch('size/getSizeList',data).then(res=> {
|
|
|
+ this.tableData = res.data.row; //给与内容
|
|
|
+ this.total = res.data.count; //给与总条数
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '网络错误,请重试!'
|
|
|
+ });
|
|
|
+ })
|
|
|
},
|
|
|
//1.6 重置
|
|
|
goReset() {
|
|
|
- this.templateStyle = ""
|
|
|
- this.templateName = ""
|
|
|
+ this.sizeHeight = ""
|
|
|
+ this.sizeWidth = ""
|
|
|
this.page=1
|
|
|
this.pageSize=10
|
|
|
this.getData()
|
|
@@ -193,18 +230,83 @@ export default {
|
|
|
//列表和分页相关 end ------------------------------------------------------------>
|
|
|
|
|
|
//1.7 编辑
|
|
|
- goEdit(id) {
|
|
|
+ goEdit(id,val) {
|
|
|
+ this.dialogName = '编辑尺寸'
|
|
|
+ this.activeid = id
|
|
|
this.dialogTableVisible = true
|
|
|
+ this.getData()
|
|
|
+
|
|
|
+ //数据回显
|
|
|
+ this.ruleForm.sizeHeight = val.height //高度
|
|
|
+ this.ruleForm.sizeWidth = val.width //宽度
|
|
|
},
|
|
|
//1.8 添加
|
|
|
addSize() {
|
|
|
this.dialogTableVisible = true
|
|
|
+ this.dialogName = "添加尺寸"
|
|
|
+ //添加时清空回显回来的数据
|
|
|
+
|
|
|
+ this.ruleForm.sizeHeight = '' //高度
|
|
|
+ this.ruleForm.sizeWidth = '' //宽度
|
|
|
},
|
|
|
|
|
|
// 弹出层相关方法 ---------------------------------------------------->
|
|
|
// 1.9 提交表单
|
|
|
submitForm() {
|
|
|
- this.dialogTableVisible = false
|
|
|
+ if (this.dialogName === "添加尺寸") {
|
|
|
+ const data = {
|
|
|
+ height: this.ruleForm.sizeHeight,
|
|
|
+ width: this.ruleForm.sizeWidth,
|
|
|
+ };
|
|
|
+ // 直接传递 data 作为参数,而不是 {data}
|
|
|
+ this.$store.dispatch('size/addSize', data).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type:'success'
|
|
|
+ });
|
|
|
+ this.dialogTableVisible = false;
|
|
|
+ this.getData();
|
|
|
+ } else if (res.code === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: res.message,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message({
|
|
|
+ message: '添加过程中出现错误,请重试',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (this.dialogName == "编辑尺寸") {
|
|
|
+ const data = {
|
|
|
+ id: this.activeid,
|
|
|
+ height: this.ruleForm.sizeHeight,
|
|
|
+ width: this.ruleForm.sizeWidth,
|
|
|
+ };
|
|
|
+ this.$store.dispatch('size/upSize', data).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ message: '编辑成功',
|
|
|
+ type:'success'
|
|
|
+ });
|
|
|
+ this.dialogTableVisible = false;
|
|
|
+ this.getData();
|
|
|
+ } else if (res.code === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: res.message,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message({
|
|
|
+ message: '编辑过程中出现错误,请重试',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
// 1.10 取消提交
|
|
|
cancelForm(){
|
|
@@ -213,7 +315,7 @@ export default {
|
|
|
// 弹出层相关方法 end ---------------------------------------------------->
|
|
|
},
|
|
|
mounted() {
|
|
|
-
|
|
|
+ this.getData()
|
|
|
},
|
|
|
}
|
|
|
</script>
|