智慧农业后台管理页面
guoshilong
2022-08-26 fec7909e8552e98c60f3e14efc7d208e109dc4f8
src/views/task/task.vue
@@ -68,6 +68,7 @@
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() {
@@ -101,6 +102,7 @@
        refreshBtn:false,
        columnBtn:false,
        searchShowBtn:false,
        menuWidth:300,
        column: [
          {
            label: "任务名称",
@@ -159,10 +161,11 @@
            prop: "stockId",
            hide: true,
            type: "tree",
            dicUrl: `/api/soldr/soldr/selectSol`,
            dicData:[],
            // dicUrl: `/api/soldr/soldr/selectSol`,
            props: {
              label: "spn",
              value: "id"
              value: "stockId1"
            },
            change: function (value) {
              console.log(value.value)
@@ -174,7 +177,7 @@
            hide: true,
            span: 6,
            type: "number",
            labelWidth: 110,
            // labelWidth: 110,
            display: false,
          },
          {
@@ -271,6 +274,7 @@
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        emptyBtn:false,
        column: [
          {
            label: "任务名称",
@@ -335,7 +339,7 @@
            dicUrl: `/api/soldr/soldr/selectSol`,
            props: {
              label: "spn",
              value: "id"
              value: "stockId1"
            },
            change: function (value) {
              console.log(value.value)
@@ -346,7 +350,7 @@
            prop: "stockNum",
            hide: true,
            disabled: true,
            span: 6,
            span: 7,
            type: "number",
            labelWidth: 110,
          },
@@ -553,7 +557,7 @@
    this.initData();
  },
  computed: {
    ...mapGetters(["permission", "userInfo"]),
    ...mapGetters(["permission", "userInfo","$farmId"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.task_add, false),
@@ -573,7 +577,6 @@
  watch: {
    "form.stockId": {
      handler(val) {
        console.log(val)
        var stockIdcolumn = this.findObject(this.option.column, "stockNum");
        if (val != "") {
          stockIdcolumn.display = true;
@@ -583,6 +586,14 @@
      },
      immediate: true,
    },
    '$farmId':{
      handler (newName, oldName) {
          this.getLandList()
          this.getSoldrList()
          this.query={}
          this.onLoad(this.page)
      }
    }
  },
  methods: {
    //入库
@@ -628,15 +639,29 @@
      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");
          that.landList = res.data.data;
          landIdcolumn.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 +680,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 +740,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 +781,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;