修改商品参数中部分bug
This commit is contained in:
		
							parent
							
								
									cdc673da06
								
							
						
					
					
						commit
						d3a49f3f3e
					
				@ -1,18 +1,18 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div style="width: 100%;">
 | 
					  <div style="width: 100%">
 | 
				
			||||||
 | 
					 | 
				
			||||||
    <Card>
 | 
					    <Card>
 | 
				
			||||||
      <Button @click="handleAddParamsGroup" type="primary">添加</Button>
 | 
					      <Button @click="handleAddParamsGroup" type="primary">添加</Button>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    </Card>
 | 
					    </Card>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class="row">
 | 
					    <div class="row">
 | 
				
			||||||
      <Card v-if="paramsGroup.length==0">
 | 
					      <Card v-if="paramsGroup.length == 0"> 暂无参数绑定信息 </Card>
 | 
				
			||||||
        暂无参数绑定信息
 | 
					 | 
				
			||||||
      </Card>
 | 
					 | 
				
			||||||
      <div class="paramsGroup" v-else>
 | 
					      <div class="paramsGroup" v-else>
 | 
				
			||||||
 | 
					        <Card
 | 
				
			||||||
        <Card style="width: 350px; margin:7px;" v-for="(group,index) in paramsGroup" :key="index" :bordered="false">
 | 
					          style="width: 350px; margin: 7px"
 | 
				
			||||||
 | 
					          v-for="(group, index) in paramsGroup"
 | 
				
			||||||
 | 
					          :key="index"
 | 
				
			||||||
 | 
					          :bordered="false"
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          <p slot="title">
 | 
					          <p slot="title">
 | 
				
			||||||
            <Icon type="ios-film-outline"></Icon> {{ group.groupName }}
 | 
					            <Icon type="ios-film-outline"></Icon> {{ group.groupName }}
 | 
				
			||||||
          </p>
 | 
					          </p>
 | 
				
			||||||
@ -23,35 +23,60 @@
 | 
				
			|||||||
                <Icon type="ios-arrow-down"></Icon>
 | 
					                <Icon type="ios-arrow-down"></Icon>
 | 
				
			||||||
              </a>
 | 
					              </a>
 | 
				
			||||||
              <Dropdown-menu slot="list">
 | 
					              <Dropdown-menu slot="list">
 | 
				
			||||||
                <Dropdown-item @click.native="handleEditParamsGroup(group)">编辑</Dropdown-item>
 | 
					                <Dropdown-item @click.native="handleEditParamsGroup(group)"
 | 
				
			||||||
                <Dropdown-item @click.native="handleDeleteParamGroup(group)">删除</Dropdown-item>
 | 
					                  >编辑</Dropdown-item
 | 
				
			||||||
 | 
					                >
 | 
				
			||||||
 | 
					                <Dropdown-item @click.native="handleDeleteParamGroup(group)"
 | 
				
			||||||
 | 
					                  >删除</Dropdown-item
 | 
				
			||||||
 | 
					                >
 | 
				
			||||||
              </Dropdown-menu>
 | 
					              </Dropdown-menu>
 | 
				
			||||||
            </Dropdown>
 | 
					            </Dropdown>
 | 
				
			||||||
            <Icon type="arrow-down-b"></Icon>
 | 
					            <Icon type="arrow-down-b"></Icon>
 | 
				
			||||||
          </p>
 | 
					          </p>
 | 
				
			||||||
          <template v-if="group.params && group.params.length > 0">
 | 
					          <template v-if="group.params && group.params.length > 0">
 | 
				
			||||||
            <div v-for="(param,paramId) in group.params" :key="paramId" class="params">
 | 
					            <div
 | 
				
			||||||
 | 
					              v-for="(param, paramId) in group.params"
 | 
				
			||||||
 | 
					              :key="paramId"
 | 
				
			||||||
 | 
					              class="params"
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
              <span>{{ param.paramName }}</span>
 | 
					              <span>{{ param.paramName }}</span>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              <span>
 | 
					              <span>
 | 
				
			||||||
                <i-button type="text" @click="handleEditParams(group, param)">编辑</i-button>
 | 
					                <i-button type="text" @click="handleEditParams(group, param)"
 | 
				
			||||||
                <i-button type="text" size="small" style="color: #f56c6c"
 | 
					                  >编辑</i-button
 | 
				
			||||||
                          @click="handleDeleteParam(group, param)">删除</i-button>
 | 
					                >
 | 
				
			||||||
 | 
					                <i-button
 | 
				
			||||||
 | 
					                  type="text"
 | 
				
			||||||
 | 
					                  size="small"
 | 
				
			||||||
 | 
					                  style="color: #f56c6c"
 | 
				
			||||||
 | 
					                  @click="handleDeleteParam(group, param)"
 | 
				
			||||||
 | 
					                  >删除</i-button
 | 
				
			||||||
 | 
					                >
 | 
				
			||||||
              </span>
 | 
					              </span>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          </template>
 | 
					          </template>
 | 
				
			||||||
          <div v-else style="align-content: center">暂无数据...</div>
 | 
					          <div v-else style="align-content: center">暂无数据...</div>
 | 
				
			||||||
          <div style="text-align: center">
 | 
					          <div style="text-align: center">
 | 
				
			||||||
            <i-button type="text" @click="handleAddParams(group)">添加</i-button>
 | 
					            <i-button type="text" @click="handleAddParams(group)"
 | 
				
			||||||
 | 
					              >添加</i-button
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </Card>
 | 
					        </Card>
 | 
				
			||||||
 | 
					 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <Modal :title="modalTitle" v-model="dialogParamsVisible" :mask-closable="false" :width="500">
 | 
					      <Modal
 | 
				
			||||||
        <Form ref="paramForm" :model="paramForm" :label-width="100" :rules="formValidate">
 | 
					        :title="modalTitle"
 | 
				
			||||||
 | 
					        v-model="dialogParamsVisible"
 | 
				
			||||||
 | 
					        :mask-closable="false"
 | 
				
			||||||
 | 
					        :width="500"
 | 
				
			||||||
 | 
					      >
 | 
				
			||||||
 | 
					        <Form
 | 
				
			||||||
 | 
					          ref="paramForm"
 | 
				
			||||||
 | 
					          :model="paramForm"
 | 
				
			||||||
 | 
					          :label-width="100"
 | 
				
			||||||
 | 
					          :rules="formValidate"
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          <FormItem label="参数名称" prop="paramName">
 | 
					          <FormItem label="参数名称" prop="paramName">
 | 
				
			||||||
            <Input v-model="paramForm.paramName" style="width: 100%" />
 | 
					            <Input v-model="paramForm.paramName" style="width: 100%" />
 | 
				
			||||||
          </FormItem>
 | 
					          </FormItem>
 | 
				
			||||||
@ -77,32 +102,61 @@
 | 
				
			|||||||
            </Select>
 | 
					            </Select>
 | 
				
			||||||
          </FormItem>
 | 
					          </FormItem>
 | 
				
			||||||
          <FormItem label="选项" prop="specName3">
 | 
					          <FormItem label="选项" prop="specName3">
 | 
				
			||||||
            <Checkbox label=1 v-model="paramForm.required">必填</Checkbox>
 | 
					            <Checkbox label="1" v-model="paramForm.required">必填</Checkbox>
 | 
				
			||||||
            <Checkbox label=1 v-model="paramForm.isIndex">可索引</Checkbox>
 | 
					            <Checkbox label="1" v-model="paramForm.isIndex">可索引</Checkbox>
 | 
				
			||||||
          </FormItem>
 | 
					          </FormItem>
 | 
				
			||||||
          <FormItem label="排序" prop="sort">
 | 
					          <FormItem label="排序" prop="sort">
 | 
				
			||||||
            <Input type="number" v-model="paramForm.sort" style="width: 100%"/>
 | 
					            <InputNumber
 | 
				
			||||||
 | 
					              :min="0"
 | 
				
			||||||
 | 
					              type="number"
 | 
				
			||||||
 | 
					              v-model="paramForm.sort"
 | 
				
			||||||
 | 
					              style="width: 100%"
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
          </FormItem>
 | 
					          </FormItem>
 | 
				
			||||||
        </Form>
 | 
					        </Form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div slot="footer">
 | 
					        <div slot="footer">
 | 
				
			||||||
          <Button type="text" @click="dialogParamsVisible = false">取消</Button>
 | 
					          <Button type="text" @click="dialogParamsVisible = false">取消</Button>
 | 
				
			||||||
          <Button type="primary" :loading="submitLoading" @click="submitParamForm">提交</Button>
 | 
					          <Button
 | 
				
			||||||
 | 
					            type="primary"
 | 
				
			||||||
 | 
					            :loading="submitLoading"
 | 
				
			||||||
 | 
					            @click="submitParamForm"
 | 
				
			||||||
 | 
					            >提交</Button
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
      </Modal>
 | 
					      </Modal>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <Modal :title="modalTitle" v-model="dialogParamsGroupVisible" :mask-closable="false" :width="500">
 | 
					      <Modal
 | 
				
			||||||
        <Form   @submit.native.prevent   @keydown.enter.native='submitParamGroupForm'   ref="paramGroupForm" :model="paramGroupForm" :label-width="100" :rules="paramGroupValidate">
 | 
					        :title="modalTitle"
 | 
				
			||||||
 | 
					        v-model="dialogParamsGroupVisible"
 | 
				
			||||||
 | 
					        :mask-closable="false"
 | 
				
			||||||
 | 
					        :width="500"
 | 
				
			||||||
 | 
					      >
 | 
				
			||||||
 | 
					        <Form
 | 
				
			||||||
 | 
					          @submit.native.prevent
 | 
				
			||||||
 | 
					          @keydown.enter.native="submitParamGroupForm"
 | 
				
			||||||
 | 
					          ref="paramGroupForm"
 | 
				
			||||||
 | 
					          :model="paramGroupForm"
 | 
				
			||||||
 | 
					          :label-width="100"
 | 
				
			||||||
 | 
					          :rules="paramGroupValidate"
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          <FormItem label="参数名称" prop="groupName">
 | 
					          <FormItem label="参数名称" prop="groupName">
 | 
				
			||||||
            <Input v-model="paramGroupForm.groupName" style="width: 100%" />
 | 
					            <Input v-model="paramGroupForm.groupName" style="width: 100%" />
 | 
				
			||||||
          </FormItem>
 | 
					          </FormItem>
 | 
				
			||||||
        </Form>
 | 
					        </Form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div slot="footer">
 | 
					        <div slot="footer">
 | 
				
			||||||
          <Button type="text" @click="dialogParamsGroupVisible = false">取消</Button>
 | 
					          <Button type="text" @click="dialogParamsGroupVisible = false"
 | 
				
			||||||
          <Button type="primary" :loading="submitLoading" @click="submitParamGroupForm">提交</Button>
 | 
					            >取消</Button
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
 | 
					          <Button
 | 
				
			||||||
 | 
					            type="primary"
 | 
				
			||||||
 | 
					            :loading="submitLoading"
 | 
				
			||||||
 | 
					            @click="submitParamGroupForm"
 | 
				
			||||||
 | 
					            >提交</Button
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
      </Modal>
 | 
					      </Modal>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
@ -139,34 +193,24 @@ export default {
 | 
				
			|||||||
      /** 参数组添加或编辑弹出框 */
 | 
					      /** 参数组添加或编辑弹出框 */
 | 
				
			||||||
      dialogParamsGroupVisible: false,
 | 
					      dialogParamsGroupVisible: false,
 | 
				
			||||||
      //参数表单
 | 
					      //参数表单
 | 
				
			||||||
      paramForm: {},
 | 
					      paramForm: {
 | 
				
			||||||
 | 
					        sort: 1,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      /** 参数值 **/
 | 
					      /** 参数值 **/
 | 
				
			||||||
      ops: {
 | 
					      ops: {
 | 
				
			||||||
        options: []
 | 
					        options: [],
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      // 参数表单
 | 
					      // 参数表单
 | 
				
			||||||
      paramGroupForm: {},
 | 
					      paramGroupForm: {},
 | 
				
			||||||
      /** 添加、编辑参数 规格 */
 | 
					      /** 添加、编辑参数 规格 */
 | 
				
			||||||
      formValidate: {
 | 
					      formValidate: {
 | 
				
			||||||
        paramName: [
 | 
					        paramName: [regular.REQUIRED, regular.VARCHAR5],
 | 
				
			||||||
          regular.REQUIRED,
 | 
					        options: [regular.REQUIRED, regular.VARCHAR255],
 | 
				
			||||||
          regular.VARCHAR5
 | 
					        sort: [regular.REQUIRED, regular.INTEGER],
 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
        options: [
 | 
					 | 
				
			||||||
          regular.REQUIRED,
 | 
					 | 
				
			||||||
          regular.VARCHAR255
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
        sort: [
 | 
					 | 
				
			||||||
          regular.REQUIRED,
 | 
					 | 
				
			||||||
          regular.INTEGER
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      /** 参数组*/
 | 
					      /** 参数组*/
 | 
				
			||||||
      paramGroupValidate: {
 | 
					      paramGroupValidate: {
 | 
				
			||||||
        groupName: [
 | 
					        groupName: [regular.REQUIRED, regular.VARCHAR5],
 | 
				
			||||||
          regular.REQUIRED,
 | 
					 | 
				
			||||||
          regular.VARCHAR5
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@ -175,6 +219,14 @@ export default {
 | 
				
			|||||||
      return val === 1 ? "输入项" : "选择项";
 | 
					      return val === 1 ? "输入项" : "选择项";
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  watch: {
 | 
				
			||||||
 | 
					    "paramForm.options": {
 | 
				
			||||||
 | 
					      handler(val) {
 | 
				
			||||||
 | 
					        this.ops.options = this.paramForm.options;
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      deep: true,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    // 初始化数据
 | 
					    // 初始化数据
 | 
				
			||||||
    init() {
 | 
					    init() {
 | 
				
			||||||
@ -198,17 +250,18 @@ export default {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    //弹出修改参数框
 | 
					    //弹出修改参数框
 | 
				
			||||||
    handleEditParams(group, param) {
 | 
					    handleEditParams(group, param) {
 | 
				
			||||||
 | 
					      console.log(group, param);
 | 
				
			||||||
      this.paramForm = {
 | 
					      this.paramForm = {
 | 
				
			||||||
        paramName: param.paramName,
 | 
					        paramName: param.paramName,
 | 
				
			||||||
        options: param.options.split(","),
 | 
					        options: param.options.split(","),
 | 
				
			||||||
        required: param.required == 1 ? true : false,
 | 
					        required: param.required == 1 ? true : false,
 | 
				
			||||||
        isIndex: param.isIndex == 1 ? true : false,
 | 
					        isIndex: param.isIndex == 1 ? true : false,
 | 
				
			||||||
        groupId: group.groupId,
 | 
					        groupId: param.groupId || "",
 | 
				
			||||||
        categoryId: this.categoryId,
 | 
					        categoryId: param.categoryId || "",
 | 
				
			||||||
        sort: param.sort,
 | 
					        sort: param.sort || 1,
 | 
				
			||||||
        id: param.id,
 | 
					        id: param.id,
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      this.ops = this.paramForm.options
 | 
					      this.ops.options = this.paramForm.options;
 | 
				
			||||||
      this.modalType = 1;
 | 
					      this.modalType = 1;
 | 
				
			||||||
      this.modalTitle = "修改参数";
 | 
					      this.modalTitle = "修改参数";
 | 
				
			||||||
      this.dialogParamsVisible = true;
 | 
					      this.dialogParamsVisible = true;
 | 
				
			||||||
@ -247,7 +300,7 @@ export default {
 | 
				
			|||||||
              }
 | 
					              }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            console.warn(this.paramGroupForm)
 | 
					            console.warn(this.paramGroupForm);
 | 
				
			||||||
            updateParamsGroup(this.paramGroupForm).then((res) => {
 | 
					            updateParamsGroup(this.paramGroupForm).then((res) => {
 | 
				
			||||||
              this.submitLoading = false;
 | 
					              this.submitLoading = false;
 | 
				
			||||||
              if (res.success) {
 | 
					              if (res.success) {
 | 
				
			||||||
@ -266,10 +319,11 @@ export default {
 | 
				
			|||||||
      this.$refs.paramForm.validate((valid) => {
 | 
					      this.$refs.paramForm.validate((valid) => {
 | 
				
			||||||
        if (valid) {
 | 
					        if (valid) {
 | 
				
			||||||
          this.submitLoading = true;
 | 
					          this.submitLoading = true;
 | 
				
			||||||
 | 
					          let data = JSON.parse(JSON.stringify(this.paramForm));
 | 
				
			||||||
 | 
					          data.isIndex = Number(data.isIndex);
 | 
				
			||||||
 | 
					          data.required = Number(data.required);
 | 
				
			||||||
          if (this.modalType === 0) {
 | 
					          if (this.modalType === 0) {
 | 
				
			||||||
            this.paramForm.isIndex = Number(this.paramForm.isIndex);
 | 
					            insertGoodsParams(data).then((res) => {
 | 
				
			||||||
            this.paramForm.required = Number(this.paramForm.required);
 | 
					 | 
				
			||||||
            insertGoodsParams(this.paramForm).then((res) => {
 | 
					 | 
				
			||||||
              this.submitLoading = false;
 | 
					              this.submitLoading = false;
 | 
				
			||||||
              if (res.success) {
 | 
					              if (res.success) {
 | 
				
			||||||
                this.$Message.success("参数添加成功");
 | 
					                this.$Message.success("参数添加成功");
 | 
				
			||||||
@ -278,10 +332,10 @@ export default {
 | 
				
			|||||||
              }
 | 
					              }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            console.warn(this.paramForm.isIndex)
 | 
					            console.warn(data.isIndex);
 | 
				
			||||||
            this.paramForm.isIndex = Number(this.paramForm.isIndex);
 | 
					            data.isIndex = Number(data.isIndex);
 | 
				
			||||||
            this.paramForm.required = Number(this.paramForm.required);
 | 
					            data.required = Number(data.required);
 | 
				
			||||||
            updateGoodsParams(this.paramForm).then((res) => {
 | 
					            updateGoodsParams(data).then((res) => {
 | 
				
			||||||
              this.submitLoading = false;
 | 
					              this.submitLoading = false;
 | 
				
			||||||
              if (res.success) {
 | 
					              if (res.success) {
 | 
				
			||||||
                this.$Message.success("参数修改成功");
 | 
					                this.$Message.success("参数修改成功");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user