智慧农业后台管理页面
tangzy
2022-06-29 537a11b572c88e304cd73de7d7028b9a3b33588f
src/views/wel/farming.vue
@@ -7,23 +7,27 @@
    width="60%"
    :visible.sync="visible"
  >
    <avue-form ref="form" v-model="form" :option="option" @submit="submit">
    <avue-form ref="form" v-if="visible"  v-model="form" :option="option" @submit="submit">
    </avue-form>
  </el-dialog>
</template>
<script>
import { mapState } from "vuex";
import { getLandList } from "@/api/land/land";
import { getUserList } from "@/api/system/user";
import { selectStockFa } from "@/api/stockfactory/stockfactory";
import { save } from "@/api/farm/farmingrecord";
import {mapState} from "vuex";
import {getLandList} from "@/api/land/land";
import {getUserList} from "@/api/system/user";
import {getDetail} from "@/api/soldr/soldr";
import {selectStockFa} from "@/api/stockfactory/stockfactory";
import {save} from "@/api/farm/farmingrecord";
export default {
  data() {
    return {
      title:"农事操作",
      form: {},
      title: "农事操作",
      form: {
        num: ''
      },
      option: {
        emptyBtn: false,
        submitText: "保存",
@@ -69,6 +73,7 @@
          {
            label: "农产品",
            prop: "strainId",
            span: 7,
            type: "tree",
            dicData: [],
            props: {
@@ -89,10 +94,11 @@
            label: "农资",
            prop: "stockId",
            type: "tree",
            span: 8,
            dicData: [],
            props: {
              label: "dictValue",
              value: "dictKey",
              label: "spn",
              value: "id",
            },
            labelWidth: 110,
            rules: [
@@ -103,13 +109,31 @@
              },
            ],
            display: false,
            change: res => {
              this.getDe(res)
            },
          },
          {
            label: "待使用数量",
            prop: "num",
            disabled: true,
            span: 4,
            display: false,
          },
          {
            label: "使用数量",
            type: "number",
            prop: "snum",
            span: 5,
            display: false,
          },
          {
            label: "作业方式",
            prop: "jobWay",
            span: 6,
            labelWidth: 110,
            type: "select",
            value:'0',
            value: '0',
            dicData: [
              {
                label: "人工",
@@ -219,32 +243,47 @@
    },
  },
  methods: {
    //计算当前时间
    getNowTime(){
        var date = new Date();
        //年 getFullYear():四位数字返回年份
        var year = date.getFullYear();  //getFullYear()代替getYear()
        //月 getMonth():0 ~ 11
        var month = date.getMonth() + 1;
        //日 getDate():(1 ~ 31)
        var day = date.getDate();
        //时 getHours():(0 ~ 23)
        var hour = date.getHours();
        //分 getMinutes(): (0 ~ 59)
        var minute = date.getMinutes();
        //秒 getSeconds():(0 ~ 59)
        var second = date.getSeconds();
        //赋值
        this.form['time'] = year + '-'
                          + this.addZero(month) + '-'
                          + this.addZero(day) + ' '
                          + this.addZero(hour);
    getDe(val) {
      if (val.value!='') {
        getDetail(val.value
        ).then(res => {
          var amount1 = res.data.data.amount1;
          this.form.num = amount1
          var numz = this.findObject(this.option.column, "num");
          var numzs = this.findObject(this.option.column, "snum");
          numz.display = true;
          numzs.display = true;
        });
      }
    },
    //小于10的拼接上0字符串
//计算当前时间
    getNowTime() {
      var date = new Date();
      //年 getFullYear():四位数字返回年份
      var year = date.getFullYear();  //getFullYear()代替getYear()
      //月 getMonth():0 ~ 11
      var month = date.getMonth() + 1;
      //日 getDate():(1 ~ 31)
      var day = date.getDate();
      //时 getHours():(0 ~ 23)
      var hour = date.getHours();
      //分 getMinutes(): (0 ~ 59)
      var minute = date.getMinutes();
      //秒 getSeconds():(0 ~ 59)
      var second = date.getSeconds();
      //赋值
      this.form['time'] = year + '-'
        + this.addZero(month) + '-'
        + this.addZero(day) + ' '
        + this.addZero(hour);
    }
    ,
//小于10的拼接上0字符串
    addZero(s) {
      return s < 10 ? ('0' + s) : s;
    },
    //初始化
    }
    ,
//初始化
    init() {
      this.form['operator'] = this.userInfo.user_id;
      //计算当前时间
@@ -276,28 +315,38 @@
          stockIdcolumn.dicData = res.data.data;
        }
      });
    },
    // 表单提交
    submit(row,done) {
    }
    ,
// 表单提交
    submit(row, done) {
      var that = this;
      row['tenantId'] = this.userInfo.tenant_id;
      row['deptId'] = this.userInfo.dept_id;
      save(row).then(
        () => {
          that.$refs.form.resetFields();
          that.visible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          done();
          window.console.log(error);
        }
      );
    },
  },
};
      if (row.snum > row.num) {
        this.$message.warning("使用农资数量大于农资数量");
        done();
      }
      else {
        save(row).then(
          () => {
            that.$refs.form.resetFields();
            that.visible = false;
            this.$message({
              type: "success",
              message: "操作成功!",
            });
            done();
          },
          (error) => {
            done();
            window.console.log(error);
          }
        );
      }
    }
    ,
  }
  ,
}
;
</script>