liuchengxin
2022-06-06 4001279159dd37942b3cf4c83ab537f95832a82d
src/views/device/peripheralUnit/index.vue
@@ -119,19 +119,20 @@
          <span>{{ scope.$index + (queryParams.pageNum - 1) * queryParams.pageSize + 1 }} </span>
        </template>
      </el-table-column>
      <el-table-column label="外设代码" width="80" align="center" prop="code"/>
      <el-table-column label="外设名称" align="center" prop="name" show-overflow-tooltip/>
      <el-table-column label="规格型号" align="center" prop="model" min-width="120"/>
      <el-table-column label="生产厂商" align="center" prop="manufacturer_dictText"/>
      <el-table-column label="厂商代码" width="100" align="center" prop="vendorCode_dictText"/>
      <el-table-column label="波特率" width="100" align="center" prop="baudRate">
      <el-table-column label="外设代码" width="80" align="center" prop="code" show-overflow-tooltip/>
      <el-table-column label="外设名称" align="center" min-width="180" prop="name" show-overflow-tooltip/>
      <el-table-column label="规格型号" align="center" prop="model" min-width="120" show-overflow-tooltip/>
      <el-table-column label="生产厂商" align="center" prop="manufacturer_dictText" min-width="200" show-overflow-tooltip/>
      <el-table-column label="厂商代码" width="100" align="center" prop="vendorCode_dictText" show-overflow-tooltip/>
      <el-table-column label="波特率" width="100" align="center" prop="baudRate" show-overflow-tooltip>
        <template slot-scope="scope">
          <dict-tag :options="dict.type.DICT103" :value="scope.row.baudRate"/>
        </template>
      </el-table-column>
      <el-table-column label="问询指令" align="center" width="180" prop="readInstruction"/>
      <el-table-column label="返回长度" width="80" align="center" prop="loopLength"/>
      <el-table-column label="功能描述" align="center" min-width="300" show-overflow-tooltip prop="description"/>
      <el-table-column label="问询指令" align="center" width="220" prop="readInstruction" show-overflow-tooltip/>
      <el-table-column label="指令长度" width="80" align="center" prop="orderLength" show-overflow-tooltip/>
      <el-table-column label="返回长度" width="80" align="center" prop="loopLength" show-overflow-tooltip/>
<!--      <el-table-column label="解析说明" align="center" min-width="300" show-overflow-tooltip prop="description"/>-->
      <el-table-column label="操作" align="center" fixed="right" width="240" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
@@ -179,7 +180,7 @@
    />
    <!-- 添加或修改外设单元对话框 -->
    <Dialog :title="title" :visible.sync="open" width="50%" append-to-body>
    <Dialog :title="title" :visible.sync="open" width="50%" :append-to-body="true" :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="外设代码" prop="code">
          <el-input v-model="form.code" placeholder="请输入外设代码" :disabled="disabled"/>
@@ -216,18 +217,21 @@
        <el-form-item label="问询指令" prop="readInstruction">
          <el-input v-model="form.readInstruction" placeholder="请输入问询指令" :disabled="disabled"/>
        </el-form-item>
        <el-form-item label="返回长度" prop="loopLength">
          <el-input v-model="form.loopLength" placeholder="请输入返回长度" :disabled="disabled"/>
        <el-form-item label="指令长度" prop="orderLength">
          <el-input v-model="form.orderLength" type="number" placeholder="请输入指令长度" :disabled="disabled"/>
        </el-form-item>
        <el-form-item label="功能描述" prop="description">
          <el-input v-model="form.description" type="textarea" placeholder="请输入内容" :disabled="disabled"/>
        <el-form-item label="返回长度" prop="loopLength">
          <el-input v-model="form.loopLength" type='number' placeholder="请输入返回长度" :disabled="disabled"/>
        </el-form-item>
        <el-form-item label="解析说明" prop="description">
          <el-input v-model="form.description" type="textarea" placeholder="请输入内容" maxlength="512" show-word-limit :disabled="disabled"/>
        </el-form-item>
        <el-form-item label="附件">
          <fileUpload v-model="form.filePath" :disabled="disabled"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button :loading="buttonLoading" type="primary" @click="submitForm" :disabled="disabled">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </Dialog>
@@ -236,7 +240,7 @@
    <Dialog :title="title" :visible.sync="uploadFlag" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="附件">
          <fileUpload v-model="form.filePath" limit="1"/>
          <fileUpload v-model="form.filePath" :limit="1"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
@@ -341,6 +345,9 @@
          {required: true, message: "问询指令不能为空", trigger: "blur"},
          {max: 128, message: '最多输入128个字符', trigger: 'blur' }
        ],
        orderLength: [
          {required: true, message: "指令长度不能为空", trigger: "blur"}
        ],
        loopLength: [
          {required: true, message: "返回长度不能为空", trigger: "blur"}
        ],
@@ -348,7 +355,7 @@
          {required: true, message: "附件不能为空", trigger: "blur"}
        ],
        description: [
          {max: 128, message: '最多输入128个字符', trigger: 'blur' }
          {max: 512, message: '最多输入512个字符', trigger: 'blur' }
        ]
      },
      disabled: false,
@@ -358,12 +365,12 @@
  },
  created() {
    this.getList();
    this.getManufacturerList();
  },
  methods: {
    getManufacturerList() {
      listManufacturer().then(res => {
        this.manufacturerList = res.data
        this.manufacturerList = res.data;
      })
    },
    /** 查询外设单元列表 */
@@ -373,6 +380,7 @@
        this.peripheralUnitList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.getManufacturerList();
      });
    },
    // 取消按钮
@@ -440,7 +448,7 @@
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改外设单元";
        this.title = "查看外设单元";
      });
    },
    /** 修改按钮操作 */
@@ -448,11 +456,12 @@
      this.loading = true;
      this.disabled = false
      this.reset();
      this.getManufacturerList();
      //this.getManufacturerList();
      const id = row.id || this.ids
      getPeripheralUnit(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.form.manufacturer = parseInt(this.form.manufacturer);
        this.open = true;
        this.title = "修改外设单元";
      });
@@ -461,6 +470,12 @@
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          // if(this.uploadFlag){
          //   if(!this.form.filePath){
          //     this.$modal.msgWarning("请选择上传附件");
          //     return;
          //   }
          // }
          this.buttonLoading = true;
          if (this.form.id != null) {
            updatePeripheralUnit(this.form).then(response => {