zmc
2023-12-21 635e1b3c0d48c2db884794cb8bc26d6ff1591ffa
src/views/fytz/user/components/CompBaseInfo.vue
@@ -3,6 +3,7 @@
    :form-info="_formInfo"
    :rules="rules"
    :reset="active"
    :useReset="true"
    v-model:is-edit="_edit"
    @submit="submit"
    @cancel="cancel"
@@ -44,7 +45,6 @@
</template>
<script>
import userApi from '@/api/fytz/userApi.js'
export default {
  props: {
    //基本信息
@@ -64,10 +64,6 @@
    return {
      _formInfo: null,
      _edit: false,
      locations: false,
      locationsProps: {
        checkStrictly: true
      },
      rules: {
        biNickName: [
          {
@@ -99,23 +95,20 @@
          }
        ]
      }
    }
    };
  },
  watch: {
    formInfo(nValue) {
      console.log('value', nValue)
      this._formInfo = this.parseUserInfo(nValue)
      console.log('执行了')
      this._formInfo = this.parseBaseInfo(nValue);
    },
    _edit(nValue) {
      this.$emit('update:isEdit', nValue)
      this.$emit('update:isEdit', nValue);
    }
  },
  mounted() {},
  methods: {
    // 用户基本信息格式化
    parseUserInfo(s) {
      const r = {}
    parseBaseInfo(s) {
      s._locations = {
        pCode: s.biProvinceCode,
        pName: s.biProvinceName,
@@ -125,64 +118,46 @@
        dName: s.biDistrictName,
        tCode: s.biTownCode,
        tName: s.biTownName
      }
      return s
      };
      return s;
    },
    // 创建新场景
    createBaseInfo(formObj, func) {
      return userApi
        .createUser(formObj)
        .then(() => {
          this.$emit('onSubmit', formObj)
        })
        .finally(() => {
          func()
        })
    },
    createBaseInfo(formObj, func) {},
    // 更新场景
    updateBaseInfo(formObj, func) {
      return userApi
        .updateUserInfo(formObj)
        .then(() => {
          this.$emit('onSubmit', formObj)
        })
        .finally(() => {
          func()
        })
    },
    updateBaseInfo(formObj, func) {},
    submit(formObj, func) {
      // 行政区划信息填充
      const a = formObj.value._locations
      const a = formObj.value._locations;
      if ('pCode' in a) {
        formObj.value.biProvinceCode = a.pCode
        formObj.value.biProvinceCode = a.pCode;
      }
      if ('pName' in a) {
        formObj.value.biProvinceName = a.pName
        formObj.value.biProvinceName = a.pName;
      }
      if ('cCode' in a) {
        formObj.value.biCityCode = a.cCode
        formObj.value.biCityCode = a.cCode;
      }
      if ('cName' in a) {
        formObj.value.biCityName = a.cName
        formObj.value.biCityName = a.cName;
      }
      if ('dCode' in a) {
        formObj.value.biDistrictCode = a.dCode
        formObj.value.biDistrictCode = a.dCode;
      }
      if ('dName' in a) {
        formObj.value.biDistrictName = a.dName
        formObj.value.biDistrictName = a.dName;
      }
      if ('tCode' in a) {
        formObj.value.biTownCode = a.tCode
        formObj.value.biTownCode = a.tCode;
      }
      if ('tName' in a) {
        formObj.value.biTownName = a.tName
        formObj.value.biTownName = a.tName;
      }
      return this.create ? this.createBaseInfo(formObj, func) : this.updateBaseInfo(formObj, func)
      return this.create ? this.createBaseInfo(formObj, func) : this.updateBaseInfo(formObj, func);
    },
    cancel() {
      this.$emit('onCancel')
      this.$emit('onCancel');
    }
  }
}
};
</script>