linwenling
2023-08-29 b8670cd94a61846ac63573f724fcf91d8dd7be88
ruoyi-ui/src/views/self/show.vue
@@ -58,12 +58,12 @@
<!--                  <el-input v-model="individualList.sex === 1 ? '男':'女' " placeholder="" clearable :style="{width: '100%'}" :disabled="dsb">-->
<!--                  </el-input>-->
                  <template v-if="!isEditing">
                    <el-input v-model="individualList.sex === 1 ? '男':'女'" placeholder="" clearable :style="{width: '100%'}" :disabled="dsb"></el-input>
                    <el-input v-model="individualList.sex === 1 ? inds='男':inds='女'" placeholder="" clearable :style="{width: '100%'}" :disabled="dsb"></el-input>
                  </template>
                  <template v-else>
                    <el-select v-model="individualList.sex" placeholder="请选择性别" clearable :style="{width: '100%'}" :disabled="dsb">
                      <el-option label="男" value="1"></el-option>
                      <el-option label="女" value="0"></el-option>
                    <el-select v-model="inds" placeholder="请选择性别" clearable :style="{width: '100%'}" :disabled="dsb">
                      <el-option label="男" value='1'></el-option>
                      <el-option label="女" value='0'></el-option>
                    </el-select>
                  </template>
                </el-form-item>
@@ -99,13 +99,14 @@
                  <template v-if="!isEditing" >
                    <el-input v-if="individualList.maritalStatus===0" placeholder="未婚"></el-input>
                    <el-input v-if="individualList.maritalStatus===1" placeholder="已婚"></el-input>
                    <el-input v-if="individualList.maritalStatus===2" placeholder="离婚"></el-input>
                    <el-input v-if="individualList.maritalStatus===2" placeholder="未婚"></el-input>
                  </template>
                  <template v-else>
                    <el-select v-model="individualList.maritalStatus" placeholder="请选择性别" clearable :style="{width: '100%'}">
                      <el-option label="未婚" value="0"></el-option>
                      <el-option label="已婚" value="1"></el-option>
                      <el-option label="离婚" value="2"></el-option>
                    <el-select v-model="mrs" placeholder="请选择性别" clearable :style="{width: '100%'}">
                      <el-option label="未婚" value='0'></el-option>
                      <el-option label="已婚" value='1'></el-option>
                      <el-option label="离婚" value='2'></el-option>
                    </el-select>
                  </template>
                </el-form-item>
@@ -117,37 +118,50 @@
      </div>
      <div style="padding-left:30px;padding-top:30px">
        <el-col :span="6" :data="individualList">
          <div class="block" :model="individualList" >
            <el-col v-model="individualList.img" prop="img">
              <el-avatar shape="square" style="width: 200px;height: 150px;" >
          <div class="block" :model="individualList">
            <div v-if="!isEditing">
              <el-avatar shape="square" style="width: 200px; height: 150px;">
                <el-image
                  :src="'http://47.93.189.255:8080/'+ individualList.img"
                  class="el-upload-list__item-thumbnail"
                  v-if="!individualList.img"
                  src="default-avatar-url"
                  :fit="fit"
                  style="width: 100%;height: 100%;"
                  style="width: 100%; height: 100%;"
                ></el-image>
                <el-image
                  v-else
                  :src="'http://47.93.189.255:8080/' + individualList.img"
                  :fit="fit"
                  style="width: 100%; height: 100%;"
                ></el-image>
              </el-avatar>
<!--              <el-upload-->
<!--                action="#"-->
<!--                list-type="picture-card"-->
<!--                multiple-->
<!--                :http-request="requestUpload"-->
<!--                :file-list="fileList"-->
<!--              >-->
<!--                <i slot="default" class="el-icon-plus"></i>-->
<!--                <div slot="file" slot-scope="{file}">-->
<!--                  <img-->
<!--                    class="el-upload-list__item-thumbnail"-->
<!--                    :src="file.url"-->
<!--                    alt=""-->
<!--                    style="width: 147px; height: 147px"-->
<!--                    fit="cover"-->
<!--                    :preview-src-list="[file.url]"-->
<!--                  >-->
<!--                </div>-->
<!--              </el-upload>-->
         </el-col>
            </div>
            <el-upload v-else
                       class="upload-demo"
                       action="#"
                       :auto-upload="false"
                       :http-request="requestUpload"
                       :limit="1"
                       :file-list="fileList"
            >
              <el-avatar shape="square" style="width: 200px; height: 150px;">
                <el-image
                  class="el-upload-list__item-thumbnail"
                  v-if="!individualList.img"
                  src="default-avatar-url"
                  :fit="fit"
                  style="width: 100%; height: 100%;"
                ></el-image>
                <el-image
                  v-else
                  :src="'http://47.93.189.255:8080/' + individualList.img"
                  :fit="fit"
                  style="width: 100%; height: 100%;"
                ></el-image>
              </el-avatar>
            </el-upload>
            <div class="edit-text" v-if="isEditing" @click="uploadImage">点击更换图片</div>
          </div>
        </el-col>
      </div>
@@ -277,13 +291,13 @@
          <el-table-column label="开始日期" prop="startDate" sortable width="250" align="center" >
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.startDate }}</template>
              <template v-else><el-input v-model="scope.row.startDate"></el-input></template>
              <template v-else><el-input v-model="scope.row.startDate" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="结束日期" prop="endDate" sortable width="250" align="center" >
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.endDate }}</template>
              <template v-else><el-input v-model="scope.row.endDate"></el-input></template>
              <template v-else><el-input v-model="scope.row.endDate" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="主要学习经历、工作单位及任职情况" prop="content" sortable width="350" align="center" >
@@ -403,13 +417,13 @@
          <el-table-column label="开始时间" prop="startTime"  sortable width="230" align="center">
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.startTime }}</template>
              <template v-else><el-input v-model="scope.row.startTime"></el-input></template>
              <template v-else><el-input v-model="scope.row.startTime" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="结束时间" prop="endTime"  sortable width="230" align="center">
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.endTime }}</template>
              <template v-else><el-input v-model="scope.row.endTime"></el-input></template>
              <template v-else><el-input v-model="scope.row.endTime" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -438,13 +452,13 @@
          <el-table-column label="开始时间" prop="startTime"  sortable width="200" align="center">
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.startTime }}</template>
              <template v-else><el-input v-model="scope.row.startTime"></el-input></template>
              <template v-else><el-input v-model="scope.row.startTime" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="结束时间" prop="endTime"  sortable width="200" align="center">
            <template slot-scope="scope">
              <template v-if="!scope.row.isEdit">{{ scope.row.endTime }}</template>
              <template v-else><el-input v-model="scope.row.endTime"></el-input></template>
              <template v-else><el-input v-model="scope.row.endTime" type="date" placeholder="选择日期"></el-input></template>
            </template>
          </el-table-column>
          <el-table-column label="所到国家或者地区" prop="destination" sortable width="300" align="center" >
@@ -672,7 +686,6 @@
      </div>
    </el-dialog>
  </div>
</template>
@@ -699,9 +712,7 @@
export default {
  name: "show",
  dicts: ['sys_normal_disable'],
  // components: {
  //   MyComponent
  // },
  data() {
    return {
      // 遮罩层
@@ -712,6 +723,10 @@
      componentKey: 0,
      // 选中数组
      ids: [],
      //性别
      inds:undefined,
      //婚姻类别
      mrs:undefined,
      // 非单个禁用
      single: true,
      // 非多个禁用
@@ -728,7 +743,7 @@
      //个人信息数据
      individualList:[],
      isEditing: false,
      // fit:['fill'],
      fit:['cover'],
      // 个人经历数据
      experienceList: [],
      // isEdit:true,
@@ -996,6 +1011,11 @@
        this.formDat[key] = '';
      });
    },
    handleUploadSuccess(response, file) {
      // 处理文件上传成功后的回调
      this.individualList.img = response.url;
    },
    //下拉
    handleChange(activeNames) {
      // console.log(val);
@@ -1224,25 +1244,34 @@
      this.isShow=false
      this.isShow_2=true
      this.isEditing=true
      // this.isEdit=false
      if(this.individualList.maritalStatus == 0)
          this.mrs = '未婚'
      else if(this.individualList.maritalStatus == 1)
          this.mrs = '已婚'
      else
          this.mrs = '离婚'// this.isEdit=false
    },
    /** 查询自传信息 */
    getAutobiographyInfor()
    {
      let _this = this
      getCategory().then(response=>{
      getCategory().then(response => {
        // response.data.itemValues.replace("{","").replace("}","").split(",").map(elem=>{
        //   _this.typeOptions.push({"label":elem.split(":")[0], "value":elem.split(":")[0]})
        // })
        response.data.itemValues.replace("{", "").replace("}", "").split(",").map(elem => {
          const label = elem.split(":")[0].trim();
          const value = parseInt(elem.split(":")[1].trim());
          _this.typeOptions.push({ "label": label, "value": value });
          // this.getSrc1(value)
        })
      })
          // 判断 typeOptions 数组中是否已存在相同的 value
          if (!_this.typeOptions.some(option => option.value === value)) {
            _this.typeOptions.push({ "label": label, "value": value });
          }
          // console.log(_this.typeOptions)
          // _this.getSrc1(value)
        });
      });
      // if(AutobiographyList.ageEnd==null){
      //   this.AgeEnd='?'
@@ -1368,6 +1397,16 @@
    //修改后的保存
    //个人基本信息
    submitForm() {
      if(this.inds=='1')
        this.individualList.sex = 1;
      else
        this.individualList.sex = 0;
      if(this.mrs=='0')
        this.individualList.maritalStatus = 0
      else if(this.mrs == '1')
        this.individualList.maritalStatus = 1
      else
        this.individualList.maritalStatus = 2
      let ul = this.fileList.map(function (elem){
        return elem.url.replace(process.env.VUE_APP_BASE_TRUE_API,"")
      }).join(",")
@@ -1389,6 +1428,7 @@
              this.btn=false
              this.isShow_2=false
              this.isShow=true
              this.isEditing = false
            });
          } else {
            this.$modal.msgSuccess("修改失败");
@@ -1399,6 +1439,51 @@
      // 刷新页面
      // window.location.reload();
    },
    //头像修改
    uploadImage() {
      const inputElement = document.createElement("input");
      inputElement.type = "file";
      inputElement.accept = "image/*";
      inputElement.style.display = "none";
      document.body.appendChild(inputElement);
      inputElement.addEventListener("change", () => {
        const file = inputElement.files[0];
        if (file) {
          const formData = new FormData();
          formData.append("image", file);
          // 调用uploadPic接口上传图片
          axios.post("/common/upload", formData, {
            headers: {
              "Content-Type": "multipart/form-data"
            }
          }).then(response => {
            // 上传成功,获取新图片的URL
            const newImageUrl = response.data.img;
            // 假设individualList是一个对象,更新individualList.img
            this.individualList.img =   newImageUrl;
            // 假设fileList是一个数组,更新fileList中对应的图片URL
            // const index = this.fileList.findIndex(item => item.id === fileId);
            // this.fileList[index].url = newImageUrl;
            // 清除input元素并移除事件监听
            document.body.removeChild(inputElement);
            inputElement.removeEventListener("change", null);
          }).catch(error => {
            console.error("上传失败:", error);
            // 清除input元素并移除事件监听
            document.body.removeChild(inputElement);
            inputElement.removeEventListener("change", null);
          });
        }
      });
      // 触发点击事件,显示文件选择对话框
      inputElement.click();
    },
    //主要经历
    saveRowExperienceList(row) {
      this.$refs['elForm'].validate(valid => {