addCounter.vue 5.59 KB
Newer Older
xd's avatar
xd committed
1 2 3
<template>
  <div class="ct">
    <el-dialog
xd's avatar
xd committed
4
      :visible.sync="counterDialog"
xd's avatar
xd committed
5 6
      width="65%"
      :show-close="false"
xd's avatar
xd committed
7
      :before-close="handleClose"
xd's avatar
xd committed
8 9 10
    >
      <div class="choose">
        <div class="title">
xd's avatar
xd committed
11
          <div class="cg">添加柜组</div>
xd's avatar
xd committed
12 13 14 15 16
          <div class="circle" @click="handleClose">
            <d2-icon-svg name="close" class="icon" />
          </div>
        </div>
        <div class="br">
xd's avatar
xd committed
17 18 19 20 21 22 23
          <el-form
            class="searchzone"
            :model="formData"
            label-width="auto"
            ref="addCounter"
            :rules="rules"
          >
xd's avatar
xd committed
24
            <el-form-item label="柜组名称:" prop="name">
xd's avatar
xd committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
              <el-input
                size="small"
                v-model="formData.name"
                style="width:240px"
                placeholder="请输入柜组名称"
              />
            </el-form-item>
            <el-form-item label="柜组编号:">
              <el-input
                size="small"
                v-model="formData.code"
                style="width:240px"
                placeholder="请输入柜组编号"
              />
            </el-form-item>
xd's avatar
xd committed
40
            <el-form-item label="柜组负责人:" prop="people">
xd's avatar
xd committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
              <el-select
                size="small"
                v-model="formData.people"
                placeholder="请选择柜组负责人"
                style="width:240px"
              >
                <el-option
                  v-for="item in personList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="柜组编号:">
              <el-input
                size="small"
                v-model="formData.area"
                style="width:240px"
                placeholder="请输入所在区域"
              />
            </el-form-item>
xd's avatar
xd committed
63
            <div class="cs">
xd's avatar
xd committed
64
              <el-form-item label="门店:"> </el-form-item>
xd's avatar
xd committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
              <div>
                <el-transfer
                  style="text-align: left; display: inline-block"
                  v-model="value4"
                  :left-default-checked="[]"
                  :right-default-checked="[]"
                  :titles="['选择', '已选']"
                  :button-texts="['删除', '添加']"
                  @change="handleChange"
                  :data="data"
                >
                  <span slot-scope="{ option }"
                    >{{ option.key }} - {{ option.label }}</span
                  >
                </el-transfer>
              </div>
xd's avatar
xd committed
81
            </div>
xd's avatar
xd committed
82 83 84 85
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
xd's avatar
xd committed
86 87
        <el-button @click="handleCancel('addCounter')" size="small">取 消</el-button>
        <el-button type="primary" @click="handleFinish('addCounter')" size="small"
xd's avatar
xd committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    const generateData = _ => {
      const data = [];
      for (let i = 1; i <= 15; i++) {
        data.push({
          key: i,
          label: `备选项 ${i}`
        });
      }
      return data;
    };
    return {
xd's avatar
xd committed
109
      counterDialog: false,
xd's avatar
xd committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
      data: generateData(),
      value: [1],
      value4: [1],
      renderFunc(h, option) {
        return (
          <span>
            {option.key} - {option.label}
          </span>
        );
      },
      formData: {
        name: "",
        code: "",
        people: ""
      },
      personList: [
        {
          id: "1",
          name: "张三"
        },
        {
          id: "2",
          name: "李四"
        }
xd's avatar
xd committed
134 135
      ],
      rules: {
xd's avatar
xd committed
136 137 138 139 140
        name: [{ required: true, message: "请输入柜组名称", trigger: "blur" }],
        people: [
          { required: true, message: "请选择活动负责人", trigger: "change" }
        ]
      }
xd's avatar
xd committed
141 142 143
    };
  },
  methods: {
xd's avatar
xd committed
144 145 146 147 148 149 150
    handleChange() {},
    handleClose(done) {
      this.$confirm("确认关闭?")
        .then(_ => {
          this.counterDialog = false;
        })
        .catch(_ => {});
xd's avatar
xd committed
151
    },
xd's avatar
xd committed
152 153 154
    handleCancel(formName) {
      this.$refs[formName].resetFields();
      this.counterDialog = false;
xd's avatar
xd committed
155
    },
xd's avatar
xd committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
    handleFinish(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.counterDialog = false;
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
  },
   watch:{
      counterDialog(){
        if(this.counterDialog){
          if(this.$refs.addCounter){
            this.$refs.addCounter.resetFields();
          }
        }
      }
xd's avatar
xd committed
175 176 177 178 179
    }
};
</script>

<style scoped>
xd's avatar
xd committed
180 181 182
.cs {
  display: flex;
}
xd's avatar
xd committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
.choose {
  padding: 16px;
  font-size: 16px;
  font-weight: bold;
  color: rgba(56, 56, 56, 1);
  box-sizing: border-box;
}
.title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* border-bottom: 1px solid #f8f8f8; */
  padding-bottom: 10px;
}
.transfer-footer {
  margin-left: 20px;
  padding: 6px 5px;
}
.ct >>> .el-dialog__header {
  padding: 0 !important;
}
.ct >>> .el-dialog__body {
  padding: 0;
}
.ct >>> .el-transfer-panel {
  width: 250px;
}
.circle {
  width: 30px;
  height: 30px;
  line-height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(208, 2, 27, 1);
  position: relative;
}
.circle >>> .icon {
  width: 28px;
  height: 28px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.br {
  border-top: 1px solid #f8f8f8;
  border-bottom: 1px solid #f8f8f8;
  padding: 24px 60px;
}
</style>