<script>
  import wPicker from '@/components/w-picker/w-picker.vue';
  import xiaEditor from '@/components/xia-editor/xia-editor';
  import multipleSelect from '@/components/momo-multipleSelect/momo-multipleSelect';
  export default {
    data() {
      return {
        cross: '',
        ruleForm: {
          jihuabianhao: this.getUUID(),
          jihuabiaoti: '',
          fengmian: '',
          dengjishijian: '',
          jihuaxiangqing: '',
          yonghuzhanghao: '',
          yonghuxingming: '',
        },
        // 登录用户信息
        user: {},
        ro: {
          jihuabianhao: false,
          jihuabiaoti: false,
          fengmian: false,
          dengjishijian: false,
          jihuaxiangqing: false,
          yonghuzhanghao: false,
          yonghuxingming: false,
        },
      };
    },
    components: {
      wPicker,
      xiaEditor,
      multipleSelect
    },
    computed: {
      baseUrl() {
        return this.$base.url;
      },
    },
    async onLoad(options) {
      this.ruleForm.dengjishijian = this.$utils.getCurDate();
      let table = uni.getStorageSync('nowTable');
      // 获取用户信息
      let res = await this.$api.session(table);
      this.user = res.data;
      // ss读取
      this.ruleForm.yonghuzhanghao = this.user.yonghuzhanghao
      this.ro.yonghuzhanghao = true;
      this.ruleForm.yonghuxingming = this.user.yonghuxingming
      this.ro.yonghuxingming = true;
      // 如果有登录,获取登录后保存的userid
      this.ruleForm.userid = uni.getStorageSync('userid')
      if (options.refid) {
        // 如果上一级页面传递了refid,获取改refid数据信息
        this.ruleForm.refid = options.refid;
        this.ruleForm.nickname = uni.getStorageSync('nickname');
      }
      // 如果是更新操作
      if (options.id) {
        this.ruleForm.id = options.id;
        // 获取信息
        res = await this.$api.info('fuxijihua', this.ruleForm.id);
        this.ruleForm = res.data;
      }
      // 跨表
      this.cross = options.cross;
      if (options.cross) {
        var obj = uni.getStorageSync('crossObj');
        for (var o in obj) {
          if (o == 'jihuabianhao') {
            this.ruleForm.jihuabianhao = obj[o];
            this.ro.jihuabianhao = true;
            continue;
          }
          if (o == 'jihuabiaoti') {
            this.ruleForm.jihuabiaoti = obj[o];
            this.ro.jihuabiaoti = true;
            continue;
          }
          if (o == 'fengmian') {
            this.ruleForm.fengmian = obj[o].split(',')[0];
            this.ro.fengmian = true;
            continue;
          }
          if (o == 'dengjishijian') {
            this.ruleForm.dengjishijian = obj[o];
            this.ro.dengjishijian = true;
            continue;
          }
          if (o == 'jihuaxiangqing') {
            this.ruleForm.jihuaxiangqing = obj[o];
            this.ro.jihuaxiangqing = true;
            continue;
          }
          if (o == 'yonghuzhanghao') {
            this.ruleForm.yonghuzhanghao = obj[o];
            this.ro.yonghuzhanghao = true;
            continue;
          }
          if (o == 'yonghuxingming') {
            this.ruleForm.yonghuxingming = obj[o];
            this.ro.yonghuxingming = true;
            continue;
          }
        }
      }
      this.styleChange()
      this.$forceUpdate()
    },
    methods: {
      styleChange() {
        this.$nextTick(() => {
          // document.querySelectorAll('.app-update-pv . .uni-input-input').forEach(el => {
          //   el.style.backgroundColor = this.addUpdateForm.input.content.backgroundColor
          // })
        })
      },
      // 多级联动参数
      dengjishijianChange(e) {
        this.ruleForm.dengjishijian = e.target.value;
        this.$forceUpdate();
      },
      fengmianTap() {
        let _this = this;
        this.$api.upload(function(res) {
          _this.ruleForm.fengmian = 'upload/' + res.file;
          _this.$forceUpdate();
          _this.$nextTick(() => {
            _this.styleChange()
          })
        });
      },
      getUUID() {
        return new Date().getTime();
      },
      async onSubmitTap() {//跨表计算判断
        var obj;
        //更新跨表属性
        var crossuserid;
        var crossrefid;
        var crossoptnum;
        if (this.cross) {
          var statusColumnName = uni.getStorageSync('statusColumnName');
          var statusColumnValue = uni.getStorageSync('statusColumnValue');
          if (statusColumnName != '') {
            if (!obj) {
              obj = uni.getStorageSync('crossObj');
            }
            if (!statusColumnName.startsWith('[') ) {
              for (var o in obj) {
                if (o == statusColumnName) {
                  obj[o] = statusColumnValue;
                }
              }
              var table = uni.getStorageSync('crossTable');
              await this.$api.update(`${table}`, obj);
            } else {
              crossuserid = Number(uni.getStorageSync('userid'));
              crossrefid = obj['id'];
              crossoptnum = uni.getStorageSync('statusColumnName');
              crossoptnum = crossoptnum.replace(/[/, '').replace(/]/, '');
            }
          }
        }
        if (crossrefid && crossuserid) {
          this.ruleForm.crossuserid = crossuserid;
          this.ruleForm.crossrefid = crossrefid;
          let params = {
            page: 1,
            limit: 10,
            crossuserid: crossuserid,
            crossrefid: crossrefid,
          }
          let res = await this.$api.list('fuxijihua', params);
          if (res.data.total >= crossoptnum) {
            this.$utils.msg(uni.getStorageSync('tips'));
            return false;
          } else {
            //跨表计算
            if (this.ruleForm.id) {
              await this.$api.update('fuxijihua', this.ruleForm);
            } else {
              await this.$api.add('fuxijihua', this.ruleForm);
            }
            //中文解释一下内容:这是一个Vue.js组件的代码,其中包含了一些导入的组件,如wPicker、xiaEditor、multipleSelect。在数据中包含了一些属性,如cross、ruleForm和user。在onLoad方法中,通过调用一些API获取一些数据并将其存储在相应的属性中。在methods中,有一些方法,如styleChange、getUUID、onSubmitTap等,用于处理一些操作,如样式变化、生成UUID、提交表单等。代码中还包含了一些跨表计算的逻辑,用于判断是否满足条件并进行相应的操作。
          }
        }
      }
    }
  };
</script>
复习计划管理 - 添加/编辑复习计划

原文地址: https://www.cveoy.top/t/topic/n3UB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录