chenlu
2024-07-11 88eb226ff61f3ce18be4a07c8fa7dd51726aaa63
north-glass-erp/northglass-erp/src/views/sd/basicData/CreateBasicData.vue
@@ -140,6 +140,7 @@
      basic.value.input=basic.value.input+"mm"
    }
  }
  console.log(basic.value)
  request.post(`/basicData/addBasicData`, basic.value).then(res => {
    if (res.data) {
      ElMessage.success(t('basicData.msg.saveSuccess'))
@@ -172,6 +173,29 @@
  ).map((item) =>item.children.filter((item) =>item.value === value[1]))
}
const changeFile = (file) => {
  const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png' ;
  const isLt2M = file.size / 1024 / 1024 < 5;
  if (!isJPG) {
    ElMessage.warning(t('orderBasicData.msg2'))
    return
  }
  if (!isLt2M) {
    ElMessage.warning(t('orderBasicData.msg1'))
    return
  }
  return new Promise((resolve, reject) => {
    let reader = new FileReader();
    reader.readAsDataURL(file.raw);
    reader.onload = (e) => {
      resolve(e.target.result);
      basic.value.nickname=e.target.result;
    };
  });
}
</script>
@@ -184,7 +208,6 @@
            v-model="basic.basicType"
            @change="handleChange"
            :options="options"
            clearable
            placeholder=""
            :disabled="props.rowIndex"
        />
@@ -202,6 +225,23 @@
        <el-input v-model="basic.nickname"/>
      </el-col>
    </el-row>
    <el-row v-if="basic.basicType.length!==0 && basic.basicType[1]==='icon'" >
      <el-col :span="4"></el-col>
      <el-col :span="12">
        <el-upload
            v-model="basic.nickname"
            :limit="1"
            :on-change="changeFile"
            class="upload-demo"
            ref="upload"
            action="https://jsonplaceholder.typicode.com/posts/"
            :file-list="fileList"
            :auto-upload="false">
          <el-button slot="trigger" size="small" type="primary" >{{ $t('orderBasicData.selectFile') }}</el-button>
          <div slot="tip" class="el-upload__tip">{{ $t('orderBasicData.msg3') }}</div>
        </el-upload>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4"></el-col>
      <el-col :span="12">