fangyuan
2022-12-16 9ff66017debadfc89bc0c1b796684a4d1dbe2bc3
src/components/dispatch/index.vue
@@ -47,9 +47,7 @@
          <el-select
            v-model="dispatch.enforcementTeam"
            placeholder="选择中队"
            :disabled="
              squadronOptions.length !== 0 && squadronOptions ? false : true
            "
            :disabled="!(squadronOptions.length !== 0 && squadronOptions)"
            @change="handleMidChange"
          >
            <el-option
@@ -66,9 +64,7 @@
          <el-select
            v-model="dispatch.lawEnforcer"
            placeholder="请选择人员"
            :disabled="
              personOptions.length !== 0 && personOptions ? false : true
            "
            :disabled="!(personOptions.length !== 0 && personOptions)"
            @change="handlePerChange"
          >
            <el-option
@@ -111,7 +107,7 @@
      </div>
    </el-form>
    <div class="map">
      <!-- <MyMap></MyMap> -->
      <MyMap></MyMap>
    </div>
    <div class="footer">
      <el-button type="primary" @click="handleDispatch">确定</el-button>
@@ -121,15 +117,15 @@
</template>
<script>
import MyMap from "@/components/map";
import { parseTime } from "@/utils/index";
export default {
  components: {
    MyMap,
  },
  props: ["id", "changeDialog", "refresh", "mytype"],
  props: ["id", "changeDialog", "refresh", "mytype", "isGetData"],
  created() {
    // 判断车辆类型
    this.mytype === 1 ? this.getLawCarList() : this.getSoilCarList();
    this.isGetDispatchData = this.isGetData ? this.isGetData : false;
    this.getDepartList();
  },
  data() {
@@ -150,13 +146,6 @@
        callback();
      } else {
        callback(new Error("派遣意见不能为空"));
      }
    };
    const checkDistance = (rule, value, callback) => {
      if (value) {
        callback();
      } else {
        callback(new Error("距离不能为空"));
      }
    };
    const checkTeam = (rule, value, callback) => {
@@ -218,12 +207,6 @@
        dispatchOpinion: [
          { required: true, trigger: "change", validator: checkOpinion },
        ],
        // distance: [
        //   { required: true, trigger: "change", validator: checkDistance },
        // ],
        // enforcementTeam: [
        //     { required: true, trigger: 'change', validator: checkTeam }
        // ],
        lawEnforcer: [
          { required: true, trigger: "change", validator: checkPerson },
        ],
@@ -238,57 +221,38 @@
          },
        ],
      },
      carOptions: [
        {
          label: "车辆一",
          value: 1,
        },
        {
          label: "车辆二",
          value: 2,
        },
      ],
      carOptions: [],
      departOptions: [],
      carOptions: [
        {
          label: "车辆一",
          value: 1,
        },
        {
          label: "车辆二",
          value: 2,
        },
      ],
      squadronOptions: [],
      personOptions: [],
      isGetDispatchData: true
    };
  },
  methods: {
    // 执行调度
    handleDispatch() {
      console.log(this.dispatch);
      this.$refs.form.validate((valid) => {
        console.log(valid);
        if (valid) {
          const { dispatch, id } = this;
          // dispatch.disposeDate = new Date();
          console.log(id);
          dispatch.baseCaseId = id;
          console.log(dispatch);
          this.$axios({
            method: "post",
            url: `sccg/dispatch_handle/dispatch`,
            data: dispatch,
          }).then((res) => {
            this.$message({
              type: res.code === 200 ? "success" : "error",
              message: res.code === 200 ? "调度成功" : res.message,
          if (this.isGetDispatchData) {
            this.$emit('getDispatchData', this.dispatch);
          } else {
            const { dispatch, id } = this;
            dispatch.baseCaseId = id;
            this.$axios({
              method: "post",
              url: `sccg/dispatch_handle/dispatch`,
              data: dispatch,
            }).then((res) => {
              this.$message({
                type: res.code === 200 ? "success" : "error",
                message: res.code === 200 ? "调度成功" : res.message,
              });
              this.refresh();
            });
            this.$emit("changeDialog", { flag: false });
            this.refresh();
          });
          }
          this.$emit("changeDialog", { flag: false });
        } else {
          return false;
          this.$message.warning('请检查必填项');
        }
      });
    },
@@ -303,17 +267,15 @@
        url: `sccg/car_Manage/query_enforce?current=1&size=1000`,
      }).then((res) => {
        this.carOptions = res.data.records;
        console.log(res, this.carOptions);
      });
    },
    // 获取渣土车辆
    getSoilCarList() {
      this.$axios({
        method: "get",
        url: `sccg/car_Manage/query_slag?current=1&size=1000`,
        url: `sccg/car_Manage/query_enforce?current=1&size=1000`,
      }).then((res) => {
        this.carOptions = res.data.records;
        console.log(res);
      });
    },
    // 获取顶级部门
@@ -327,7 +289,6 @@
    },
    // 获取中队
    async getTeamList(id) {
      console.log(id);
      await this.$axios({
        method: "get",
        url: `sccg/depart/query_father_children?fatherId=${id}`,
@@ -336,18 +297,15 @@
          this.squadronOptions = res.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 获取部门下的用户
    async getDepartUserList(id) {
      console.log(id);
      await this.$axios({
        method: "get",
        url: `sccg/admin/getDepartUser/${id}`,
      })
        .then((res) => {
          console.log(res);
          if (res.code === 200) {
            this.personOptions = res.data;
          } else {
@@ -374,9 +332,6 @@
      this.dispatch.contactWay = "";
      this.dispatch.lawEnforcerName = "";
      await this.getTeamList(id);
      // if (this.squadronOptions.length === 0) {
      //     await this.getDepartUserList(id);
      // }
    },
    // 中队更改
    async handleMidChange(id) {
@@ -406,9 +361,7 @@
  watch: {
    "squadronOptions.length": {
      handler(newval, oldval) {
        console.log(newval);
        if (newval === 0) {
          console.log(1);
          this.$message({
            type: "warning",
            message: "该部门下没有中队",