index.js 5.38 KB
import Api from "~/service/Api"
import commonFunctions from '~/mixin/commonFunctions.js';
export default {
  mixins: [commonFunctions],
  methods: {
    search() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          let data = this.model;
          Api.post(`/Domlc/elcsnd/search`, data).then(res => {
            this.model.elcsList = res.data;
          });
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    show() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          if (this.currentZcinvlstIndex === -1) {
            this.$notify.error({
              title: "错误",
              message: "请选择一条数据!"
            });
            return;
          }
          let data = this.model.elcsList[this.currentZcinvlstIndex].inr;
          Api.post(`/Domlc/elcsnd/show`, data).then(res => {
            this.model.formatData = res.data.formatData;
            this.model.textContext = res.data.data;
            this.visiable = true;
          });
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    send() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          if (this.currentZcinvlstIndex === -1) {
            this.$notify.error({
              title: "错误",
              message: "请选择一条数据!"
            });
            return;
          }
          this.$confirm('确定发送此笔报文?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(async () => {
            let data = this.model.elcsList[this.currentZcinvlstIndex].inr;
            Api.post(`/Domlc/elcsnd/send`, data).then(res => {
              this.$alert(res.data === 0 ? '发送成功' : '发送失败', '提示', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true
              });
              this.model.elcsList = null;
              this.currentZcinvlstIndex = -1;
            });
          }).catch(() => {
          })
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    delect() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          if (this.currentZcinvlstIndex === -1) {
            this.$notify.error({
              title: "错误",
              message: "请选择一条数据!"
            });
            return;
          }
          this.$confirm('确定删除此笔报文?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }).then(async () => {
            let data = this.model.elcsList[this.currentZcinvlstIndex].inr;
            Api.post(`/Domlc/elcsnd/delect`, data).then(res => {
              this.model.elcsList = null;
              this.currentZcinvlstIndex = -1;
            });
          }).catch(() => {

          })
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    modify() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          if (this.currentZcinvlstIndex === -1) {
            this.$notify.error({
              title: "错误",
              message: "请选择一条数据!"
            });
            return;
          }
          let id = this.model.elcsList[this.currentZcinvlstIndex].inr;
          this.routerPush({
            path: "/business/elcadd",
            query: { id: id, }
          });
          this.currentZcinvlstIndex = -1;
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    details() {
      // 前端检验
      this.$refs["ElcsndForm"].validate((valid) => {
        if (valid) {
          if (this.currentZcinvlstIndex === -1) {
            this.$notify.error({
              title: "错误",
              message: "请选择一条数据!"
            });
            return;
          }
          let id = this.model.elcsList[this.currentZcinvlstIndex].inr;
          this.routerPush({
            path: "/review/review-elcadd",
            query: { id: id, action:"read" }
          });
          this.currentZcinvlstIndex = -1;
        } else {
          // 前端校验失败
          this.$notify({
            title: '失败',
            message: '校验失败',
            type: 'error',
          });
          return false;
        }
      });
    },
    handleRowClick(row) {
      this.currentZcinvlstIndex = row.index
    },
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex;
    },
  }
}