licp
2024-03-29 41cad2434411b2eac1b9814d47d06e34c291f285
src/views/equipment/mould/index.vue
@@ -2,33 +2,182 @@
  <div class="mod-config">
      <basic-container>
        <ttable
        @handleSelectionChange="handleSelectionChange"
        :table="table"
        :uploadInfo="uploadInfo"
        :ajaxFun="ajaxFun"
        :prelang="prelang"
        :options="options"
        ref="mouldTable"
        class="mouldTable"
        >
        <template #toolbar></template>
        <template #toolbar>
            <el-dropdown
            @command="handleCommand"
          >
            <el-button>
              状态改变<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :command="item.value"
                v-for="item in optList"
                >{{ item.label }}</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </template>
        </ttable>
      </basic-container>
      <el-dialog
        :title="editRow==null ? '新增':'修改'"
        :title="editRow.id==null ? '新增':'修改'"
        :visible.sync="dialogVisible"
        width="40%">
            <el-form :model="editRow" label-position="right" label-width="100px" ref="editForm" :rules="editRules">
                <el-form-item prop="code" label="模具编码">
                    <el-input v-model="editRow.code" placeholder="请输入模具编码称"></el-input>
                </el-form-item>
                <el-form-item prop="name" label="模具名称">
                    <el-input v-model="editRow.name" placeholder="请输入模具名称"></el-input>
                </el-form-item>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="model" label="模具型号">
                            <el-input v-model="editRow.model" placeholder="请输入模具型号" :disabled="editRow.id"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="name" label="模具名称">
                            <el-input v-model="editRow.name" placeholder="请输入模具名称"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="status" label="模具状态">
                            <el-select v-model="editRow.status" placeholder="请选择模具状态" style="width: 100%;">
                                <el-option
                                v-for="item in optList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="drawingNo" label="模具图号">
                            <el-input v-model="editRow.drawingNo" placeholder="请输入模具图号"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="workShop" label="车间">
                            <el-select v-model="editRow.workShop" placeholder="请选择车间" style="width: 100%;">
                                <el-option
                                v-for="item in workshopList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="shelfNo" label="货架号">
                            <el-input v-model="editRow.shelfNo" placeholder="请输入货架号"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="erpOrder" label="ERP订单号">
                            <el-input v-model="editRow.erpOrder" placeholder="请输入ERP订单号"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="texture" label="材质">
                            <el-input v-model="editRow.texture" placeholder="请输入材质"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="supplier" label="供应商">
                            <el-input v-model="editRow.supplier" placeholder="请输入供应商"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="userTime" label="投入使用日期">
                            <el-date-picker
                            v-model="editRow.userTime"
                            type="datetime"
                            placeholder="请投入使用日期"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss" style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="serviceLife" label="使用寿命">
                            <el-input v-model="editRow.serviceLife" placeholder="请输入使用寿命"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="number" label="已使用次数">
                            <el-input v-model="editRow.number" placeholder="请输入已使用次数"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="16">
                    <el-col :span="12">
                        <el-form-item prop="person" label="责任人">
                            <el-input v-model="editRow.person" placeholder="请输入责任人"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="remark" label="备注">
                            <el-input v-model="editRow.remark" placeholder="请输入备注" type="textarea" :rows="3"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmSaveOrUpdateMould">确 定</el-button>
        </span>
        </el-dialog>
        <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="6" :offset="1">编号:</el-col>
              <el-col :span="12" style="font-weight: bold;">{{ tem.code }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="6" :offset="1">模具名称:</el-col>
              <el-col :span="12" style="font-weight: bold;">{{ tem.name }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="6" :offset="1">模具位置:</el-col>
              <el-col :span="12" style="font-weight: bold;">{{ tem.workShop }}-{{tem.shelfNo}}</el-col>
            </el-row>
            <el-row>
              <el-col :span="6" :offset="1">模具二维码:</el-col>
              <el-col :span="7">
                <vueQr :text="tem.code" :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>
@@ -37,20 +186,33 @@
import * as fecha from 'element-ui/lib/utils/date'
import { fetchList,addMould,updateMould,delById } from '@/api/equipment/moulde'
import { mapGetters } from 'vuex'
import { remote } from '@/api/admin/dict'
import vueQr from 'vue-qr'
import PrintJS from 'print-js'
export default {
  data(){
      return {
          diaPrintTab: false,
          editRules: {
            code: [{required:true,message:'请输入模具编号',trigger:'blur'}],
            name: [{required:true,message:'请输入模具名称',trigger:'blur'}]
            model: [{required:true,message:'请输入模具型号',trigger:'blur'}],
            name: [{required:true,message:'请输入模具名称',trigger:'blur'}],
            status: [{required:true,message:'请选择模具状态',trigger:'change'}]
          },
          editRow: {
            code: null,
            name: null,
          },
          uploadInfo: {
            // 是否展示上传EXCEL以及对应的url
            isShow: true,
            url: '/mes/mould/upload',
            download: true,
            fileName: '模具统计表'
          },
          dialogVisible: false,
          ajaxFun: fetchList,
          prelang: 'moudle',
          multipleSelection: [],
          dataListLoading: false,
          options: {
              height: 300, // 默认高度-为了表头固定
@@ -92,8 +254,8 @@
                },
                {
                  minWidth: '140px',
                  prop: 'createUser',
                  label: '责任人',
                  prop: 'drawingNo',
                  label: '模具图号',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
@@ -104,8 +266,99 @@
                  label: '模具状态',
                  isTrue: true,
                  isSearch: true,
                  isTags:true,
                  searchInfoType: 'select',
                  formatter: this.workShopFormatter,
                  optList: () => {
                    return this.optList
                  },
                },
                {
                  minWidth: '140px',
                  prop: 'model',
                  label: '模具型号',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'workShop',
                  label: '车间',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'select',
                  formatter: this.workShopFormatter,
                  optList: () => {
                    return this.workshopList
                  }
                },
                {
                  minWidth: '140px',
                  prop: 'shelfNo',
                  label: '货架号',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'erpOrder',
                  label: 'ERP订单号',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'texture',
                  label: '材质',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'supplier',
                  label: '供应商',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'userTime',
                  label: '投入使用日期',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'date',
                  formatter: this.formatDateTime
                },
                {
                  minWidth: '140px',
                  prop: 'serviceLife',
                  label: '使用寿命',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text'
                },
                {
                  minWidth: '140px',
                  prop: 'number',
                  label: '已使用次数',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'person',
                  label: '责任人',
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text',
                },
                {
                  minWidth: '140px',
                  prop: 'createTime',
@@ -125,6 +378,29 @@
                minWidth: 100
              },
          },
          optList:[
            {
                value:'正常',
                label:'正常',
                type:'success'
            },
            {
                value:'异常',
                label:'异常',
                type:'danger'
            },
            {
                value:'返修',
                label:'返修',
                type:'warning'
            },
            {
                value:'报废',
                label:'报废',
                type:'info'
            },
            ],
        workshopList: []
     }
  },
  computed: {
@@ -132,7 +408,7 @@
  },
  components: {
    ttable,
    TableForm
    vueQr,
  },
  watch: {
    dialogVisible(newVal){
@@ -152,13 +428,6 @@
            fun: this.addOrUpdateHandle
        })
    }
    if(this.permissions.equipment_mould_lableprint){
        this.table.toolbar.push({
            text: '标签打印',
            type: 'primary',
            fun: this.lableprint
        })
    }
    if(this.permissions.equipment_mould_del){
        this.table.operator = [{
            text: '删除',
@@ -166,11 +435,28 @@
            fun: this.deleteHandle
        }]
    }
    if(this.permissions.equipment_mould_labelprint){
      this.table.toolbar.push({
              text: '标签打印',
              type: 'primary',
              fun: this.labelPrint
            })
    }
    this.table.operator = arr.length>0 ? arr : null
  },
  mounted(){
    remote('work_shop').then((response) => {
      if (response.data.code === 0) {
        this.workshopList = response.data.data
      } else {
        this.workshopList = []
      }
    })
  },
  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    deleteHandle(row){
        this.$confirm('是否确认删除模具名称为' + row.name, '提示', {
          confirmButtonText: '确定',
@@ -184,9 +470,6 @@
            this.$message.success('删除成功')
            this.getData()
          })
    },
    lableprint(){
    },
    confirmSaveOrUpdateMould(){
        this.$refs.editForm.validate(valid=>{
@@ -214,11 +497,20 @@
            }
        })
    },
    workShopFormatter(row, column, cellValue) {
      this.workshopList.forEach((obj) => {
        if (obj.value == cellValue) {
          cellValue = obj.label
        }
      })
      return cellValue
    },
    addOrUpdateHandle(row){
        if(row){
            this.editRow = row
        }
        this.dialogVisible = true
        this.$refs["editForm"].clearValidate()
    },
    formatDateTime(row, column, cellValue) {
        return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd HH:mm:ss') : ''
@@ -226,6 +518,59 @@
    getData() {
      this.$refs.mouldTable.getDataList()
    },
    // 标记状态
    handleCommand(event) {
      if (this.multipleSelection && this.multipleSelection.length > 0) {
        this.multipleSelection.forEach((item) => {
            item.status = event;
            updateMould(item).then(res=>{
                if(res.status===200){
                    // this.$message.success("修改成功")
                    this.getData()
                }
            }).catch(error=>{
                console.error(error)
            })
        })
        this.$message.success('改变' + event + '成功')
      } else {
        this.$message.error('请选择模具')
      }
    },
    labelPrint(){
        if(this.multipleSelection.length==0){
          this.$message.warning('请选择一条数据')
          return
        }
        this.diaPrintTab = true
    },
    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: '',
        });
    },
  },
}
</script>