licp
2024-03-29 41cad2434411b2eac1b9814d47d06e34c291f285
src/views/equipment/equipment/index.vue
@@ -19,16 +19,48 @@
        @refreshDataList="getData"
      ></table-form>
    </basic-container>
    <el-dialog title="标签列表" :visible.sync="diaPrintTab" width="500px" top="5vh">
      <div style="width:100%;height:400px;overflow-y: auto;">
        <div class="dia_body" id="printRaw">
          <el-card class="box-card" v-for="(tem, i) in multipleSelection" :key="i" style="margin-bottom: 10px; font-size: 16px !important;">
            <el-row>
              <el-col :span="8" :offset="1">序号:</el-col>
              <el-col :span="7" style="font-weight: bold;">{{ tem.id }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8" :offset="1">编号:</el-col>
              <el-col :span="10" style="font-weight: bold;">{{ tem.number }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8" :offset="1">设备名称:</el-col>
              <el-col :span="7" style="font-weight: bold;">{{ tem.name }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8" :offset="1">设备二维码:</el-col>
              <el-col :span="7">
                <vueQr :text="tem.number" :size="80" :margin="2"></vueQr>
              </el-col>
            </el-row>
          </el-card>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="diaPrintTab = false">取 消</el-button>
        <el-button type="primary" @click="printFun">打 印</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { delObj, fetchList } from '@/api/equipment/equipment'
import { delObj, fetchList,pullEquip } from '@/api/equipment/equipment'
import TableForm from './equipment-form'
import ttable from '@/views/common/ztt-table.vue'
import { mapGetters } from 'vuex'
import * as fecha from 'element-ui/lib/utils/date'
import { remote } from '../../../api/admin/dict'
import vueQr from 'vue-qr'
import PrintJS from 'print-js'
export default {
  data() {
    return {
@@ -36,9 +68,10 @@
      multipleSelection: [],
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: true,
        isShow: false,
        url: '/mes/equipment/upload'
      },
      diaPrintTab: false,
      prelang: 'workstation',
      options: {
        height: 300, // 默认高度-为了表头固定
@@ -64,6 +97,7 @@
          // 设备编号
          {
            minWidth: '30',
            width: '200',
            prop: 'number',
            label: '设备编号',
            sort: true,
@@ -77,8 +111,19 @@
          // 设备名称
          {
            minWidth: '30',
            width: '100',
            prop: 'name',
            label: '设备名称',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          // 状态
          {
            minWidth: '30',
            prop: 'state',
            label: '状态',
            sort: true,
            isTrue: true,
            isSearch: true,
@@ -114,19 +159,19 @@
            label: '位置',
            sort: true,
            isTrue: true,
            isSearch: false,
            isSearch: true,
            searchInfoType: 'text'
          },
          // 邮箱
          {
            minWidth: '30',
            prop: 'email',
            label: '邮箱',
            sort: true,
            isTrue: true,
            isSearch: false,
            searchInfoType: 'text'
          },
          // {
          //   minWidth: '30',
          //   prop: 'email',
          //   label: '邮箱',
          //   sort: true,
          //   isTrue: true,
          //   isSearch: false,
          //   searchInfoType: 'text'
          // },
          // 供应商
          {
            minWidth: '30',
@@ -134,7 +179,7 @@
            label: '供应商',
            sort: true,
            isTrue: true,
            isSearch: false,
            isSearch: true,
            searchInfoType: 'text'
          },
          // 制造商
@@ -144,7 +189,7 @@
            label: '制造商',
            sort: true,
            isTrue: true,
            isSearch: false,
            isSearch: true,
            searchInfoType: 'text'
          },
          // 型号规格
@@ -154,13 +199,13 @@
            label: '型号规格',
            sort: true,
            isTrue: true,
            isSearch: false,
            isSearch: true,
            searchInfoType: 'text'
          },
          // 制造日期
          {
            minWidth: '150',
            width: '250',
            width: '100',
            prop: 'manufactureDate',
            label: '制造日期',
            sort: true,
@@ -172,7 +217,7 @@
          // 安装日期
          {
            minWidth: '150',
            width: '250',
            width: '100',
            prop: 'installDate',
            label: '安装日期',
            sort: true,
@@ -180,41 +225,10 @@
            isSearch: true,
            formatter: this.formatReceiveTime,
            searchInfoType: 'datetimerange'
          },
          // 状态
          {
            minWidth: '30',
            prop: 'state',
            label: '状态',
            sort: true,
            isTrue: true,
            isSearch: false,
            searchInfoType: 'text'
          }
        ],
        toolbar: [
          {
            text: '新增',
            type: 'primary',
            fun: this.addOrUpdateHandle
          }
        ],
        operator: [
          {
            text: '修改',
            icon: 'el-icon-edit',
            type: 'text',
            size: 'small',
            fun: this.addOrUpdateHandle
          },
          {
            text: '删除',
            icon: 'el-icon-delete',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
          }
        ],
        toolbar: [],
        operator: null,
        operatorConfig: {
          fixed: 'right',
          label: '操作',
@@ -228,12 +242,55 @@
  },
  components: {
    ttable,
    TableForm
    TableForm,
    vueQr
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  created() {
    if(this.permissions.equipment_equipment_add){
      this.table.toolbar.push({
            text: '新增',
            type: 'primary',
            fun: this.addOrUpdateHandle
          })
    }
    if(this.permissions.equipment_equipment_labelprint){
      this.table.toolbar.push({
              text: '标签打印',
              type: 'primary',
              fun: this.labelPrint
            })
    }
    if(this.permissions.equipment_equipment_sync){
      this.table.toolbar.push({
            text: '同步',
            type: 'primary',
            loading: false,
            fun: this.pullEquipFun
          })
    }
    let arr = []
    if(this.permissions.equipment_equipment_edit){
      arr.push({
            text: '修改',
            icon: 'el-icon-edit',
            type: 'text',
            size: 'small',
            fun: this.addOrUpdateHandle
          })
    }
    if(this.permissions.equipment_equipment_del){
      arr.push({
            text: '删除',
            icon: 'el-icon-delete',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
          })
    }
    this.table.operator = arr.length>0 ? arr : null
    remote('work_shop').then((response) => {
      if (response.data.code === 0) {
        this.workshopList = response.data.data
@@ -243,6 +300,44 @@
    })
  },
  methods: {
    printFun() {
            // this.printDialogVisible = false;
            this.diaPrintTab = false;
            PrintJS({
                printable: 'printRaw',//页面
                type: "html",//文档类型
                  maxWidth:450,
                  targetStyles:['*'],
                  style: `@page {
                    margin:0;
                    padding: 0;
                    size: 360px 170px landscape;
                  }
                  html{
                    zoom:100%;
                  }
                  @media print{
                    width: 360px;
                    height: 170px;
                    margin:0;
                    padding: 0;
                  }`,
                  onPrintDialogClose: this.erexcel=false,
                  targetStyles: ["*"], // 使用dom的所有样式,很重要
                  font_size: '',
            });
        },
    pullEquipFun(){
      this.table.toolbar.find((e) => e.text === '同步').loading = true
      pullEquip().then(res=>{
        this.$message.success(res.data.msg)
        this.table.toolbar.find((e) => e.text === '同步').loading = false
      }).catch(error=>{
        this.$message.error("同步失败",error)
        this.getData()
        this.table.toolbar.find((e) => e.text === '同步').loading = false
      })
    },
    workShopFormatter(row, column, cellValue) {
      this.workshopList.forEach((obj) => {
        if (obj.value == cellValue) {
@@ -283,7 +378,14 @@
          this.$message.success('删除成功')
          this.getData()
        })
    }
    },
    labelPrint(){
        if(this.multipleSelection.length==0){
          this.$message.warning('请选择一条数据')
          return
        }
        this.diaPrintTab = true
      }
  }
}
</script>