智慧农业后台管理页面
guoshilong
2022-09-27 afa8ee521affdce4f4cac9ba32ede9d22b76a13e
src/views/task/task.vue
@@ -68,9 +68,18 @@
import {getList, getDetail, add, update, remove, updatechuli} from "@/api/task/task";
import {mapGetters} from "vuex";
import {getLandList} from "@/api/land/land";
import {selectStockFa} from "@/api/stockfactory/stockfactory";
export default {
  data() {
    const validateNum = (rule, value, callback) => {
      if (!/^[1-9]\d*$/.test(value)) {
        callback(new Error("请输入正整数"));
      } else {
        callback();
      }
    };
    return {
      form: {},
      query: {},
@@ -101,6 +110,7 @@
        refreshBtn:false,
        columnBtn:false,
        searchShowBtn:false,
        menuWidth:300,
        column: [
          {
            label: "任务名称",
@@ -159,13 +169,14 @@
            prop: "stockId",
            hide: true,
            type: "tree",
            dicUrl: `/api/soldr/soldr/selectSol`,
            dicData:[],
            // dicUrl: `/api/soldr/soldr/selectSol`,
            props: {
              label: "spn",
              value: "id"
            },
            change: function (value) {
              console.log(value.value)
              // console.log(value.value)
            }
          },
          {
@@ -174,8 +185,13 @@
            hide: true,
            span: 6,
            type: "number",
            labelWidth: 110,
            // labelWidth: 110,
            display: false,
            rules:[{
              require:false,
              trigger: "blur",
              validator: validateNum
            }]
          },
          {
            label: "拍照照片",
@@ -271,6 +287,7 @@
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        emptyBtn:false,
        column: [
          {
            label: "任务名称",
@@ -338,7 +355,7 @@
              value: "id"
            },
            change: function (value) {
              console.log(value.value)
              // console.log(value.value)
            }
          },
          {
@@ -346,7 +363,7 @@
            prop: "stockNum",
            hide: true,
            disabled: true,
            span: 6,
            span: 7,
            type: "number",
            labelWidth: 110,
          },
@@ -479,7 +496,7 @@
              value: "stock_id1"
            },
            change: function (value) {
              console.log(value.value)
              // console.log(value.value)
            }
          },
          {
@@ -494,6 +511,7 @@
          {
            label: "拍照照片",
            prop: "type",
            value:"1",
            span: 6,
            disabled: true,
            type: "switch",
@@ -553,7 +571,7 @@
    this.initData();
  },
  computed: {
    ...mapGetters(["permission", "userInfo"]),
    ...mapGetters(["permission", "userInfo","$farmId"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.task_add, false),
@@ -573,7 +591,6 @@
  watch: {
    "form.stockId": {
      handler(val) {
        console.log(val)
        var stockIdcolumn = this.findObject(this.option.column, "stockNum");
        if (val != "") {
          stockIdcolumn.display = true;
@@ -583,11 +600,26 @@
      },
      immediate: true,
    },
    '$farmId':{
      handler (newName, oldName) {
          this.getLandList()
          this.getSoldrList()
          this.query={}
          this.onLoad(this.page)
      }
    }
  },
  methods: {
    //入库
    //处理
    submitR(row, done, loading) {
      var that = this;
      if(row.type == "0"){
        if(row.tp == ""){
          that.$message.warning("请上传照片")
          done()
          return
        }
      }
      updatechuli(row).then(
        () => {
          that.onLoad(this.page);
@@ -628,15 +660,31 @@
      this.gradeBoxVisiblechuli = true;
    },
    initData() {
      this.getLandList()
      this.getSoldrList()
    },
    getLandList(){
      var that = this;
      //获取农地数据
      getLandList(this.userInfo.dept_id).then((res) => {
      getLandList(this.$farmId).then((res) => {
        if (res.data.code == 200) {
          var landIdcolumn = that.findObject(that.option.column, "landId");
          var landIdColumnChuli = that.findObject(that.optionchuli.column,"landId")
          that.landList = res.data.data;
          landIdcolumn.dicData = res.data.data;
          landIdColumnChuli.dicData = res.data.data
        }
      })
    },
    getSoldrList(){
      var that = this;
      //获取农资
      selectStockFa(this.$farmId).then((res) => {
        if (res.data.code == 200) {
          var stockIdcolumn = that.findObject(that.option.column, "stockId");
          stockIdcolumn.dicData = res.data.data;
        }
      });
    },
    rowSave(row, done, loading) {
      if(row.tp.length<=0){
@@ -655,6 +703,14 @@
      });
    },
    rowUpdate(row, index, done, loading) {
      if(row.stockNum<0){
        this.$message({
          type: "warning",
          message: "农资量不能为负数!"
        });
        done();
        return
      }
      update(row).then(() => {
        this.onLoad(this.page);
        this.$message({
@@ -707,6 +763,9 @@
        });
    },
    beforeOpen(done, type) {
      if(["add"].includes(type)){
        this.option.disabled=false
      }
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
@@ -745,6 +804,7 @@
    },
    onLoad(page, params = {}) {
      this.loading = true;
      params["farmId"] = this.$farmId
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;