王震
2023-12-13 67da82f0b0c24df5f19bbfcfec63801d9ae902d8
src/views/quality/Packaging_ledger/index.vue
@@ -4,23 +4,23 @@
        <el-row>
            <el-col :span="11">
            <ttable
        :table="table"
        :isShowHide="true"
        :prelang="prelang"
        :options="options"
        ref="processconfiguration"
        >
        <template #toolbar></template>
            :table="table"
            :isShowHide="true"
            :prelang="prelang"
            :ajaxFun="ajaxFun"
            :options="options"
            @handleSelectionChange="handleSelectionChange"
            ref="processconfiguration"
            >
              <template #toolbar></template>
            </ttable>
            </el-col>
            <el-col :span="13" style="padding-left: 10px">
                <el-card>
                <div slot="header">
                <el-row>
                    <el-col :span="8">
                    <span>标准参数</span>
                    <span>装箱明细</span>
                    </el-col>
                    <el-col :span="8" :offset="4">
                    <!-- <el-button
@@ -32,38 +32,29 @@
                    </el-button> -->
                    </el-col>
                    <el-col :span="2">
                    <!-- <el-button
                    <el-button
                        style="float: right; padding: 3px 0"
                        type="text"
                        :disabled="isSubmit"
                        v-thinclick="`dataFormTestStandardParam`"
                        v-if="editable"
                        @click="addpreserve"
                        >保存
                    </el-button> -->
                    </el-button>
                    </el-col>
                    <el-col :span="2">
                    <!-- <el-button
                    <el-button
                        v-if="!isCheck"
                        style="float: right; padding: 3px 0"
                        type="text"
                        @click="relateOperationParam()"
                        v-if="editable"
                        >添加
                    </el-button> -->
                    </el-button>
                    </el-col>
                </el-row>
                <el-row>
                    <!-- <span style="font-weight:500" v-if="testNo.length > 0"
                    >您当前选择的检测标准编号是:<span style="color:#066EFF">{{
                        testNo
                    }}</span></span
                    > -->
                </el-row>
                </div>
                <el-table
              :data="testStandardParams"
              id="testStandardParamTable"
              ref="testStandardParam"
              :default-sort="{ prop: 'index' }"
              highlight-current-row
              height="700"
              style="width: 100%"
@@ -72,122 +63,130 @@
              stripe
            >
              <el-table-column
                prop="index"
                type ="index"
                label="序号"
                align="center"
                width="50"
              />
              <!-- <el-table-column
                label="是否引用工艺参数"
                prop="isReference"
                align="center"
              >
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.isReference"
                    placeholder="请选择"
                    style="width: 100%;"
                  >
                    <el-option
                      v-for="(item, index) in referenceOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="是否抽检" prop="isCheck" align="center">
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.isCheck"
                    placeholder="请选择"
                    style="width: 100%;"
                  >
                    <el-option
                      v-for="(item, index) in isCheckOptions"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                label="线芯"
                prop="wireCore"
                align="center"
                width="60"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.wireCore"></el-input>
                </template>
              </el-table-column> -->
              <el-table-column label="参数编号" prop="code" align="center" />
              <el-table-column
                label="参数项"
                prop="parameterItem"
                label="产品"
                prop="product"
                show-overflow-tooltip
                align="center"
              />
              <el-table-column
                label="要求范围"
                prop="referenceValue"
                label="产品编号"
                prop="productNo"
                show-overflow-tooltip
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="默认值"
                prop="defaultValue"
                label="批次号"
                prop="outBatchNo"
                show-overflow-tooltip
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="参数项类型"
                prop="paramType"
                label="规格型号"
                prop="specs"
                show-overflow-tooltip
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="参数格式"
                prop="parameterFormat"
                label="单位"
                prop="unit"
                show-overflow-tooltip
                align="center"
              >
              </el-table-column>
              <el-table-column
                label="数量"
                prop="number"
                align="center"
                show-overflow-tooltip
                width="80"
              >
              ></el-table-column>
              <el-table-column
                fixed="right"
                label="操作"
                align="center"
                width="80">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.parameterFormat"></el-input>
                  <el-button type="text" @click="deleteadd(scope.row)" icon="el-icon-delete"  size="small">删除</el-button>
                </template>
              </el-table-column><el-table-column
                label="测试方法"
                prop="purpose"
                align="center"
                width="80"
              >
              </el-table-column>
              <el-table-column
                label="测试目的"
                prop="method"
                align="center"
                width="80"
              >
              </el-table-column>
              <el-table-column label="单位" prop="unit" align="center" />
            </el-table>
                </el-card>
            </el-col>
        </el-row>
        </basic-container>
        <!-- 新增 -->
        <packfrom
        :currshowlist.sync="addOrUpdateVisible"
        @refreshDataList="getData">
        </packfrom>
        <packfromadd
        :currshowlist.sync="increase"
        :packageBoxIddata ="packageBoxId"
        @handleSelectionChange = "preserve"
        >
        </packfromadd>
      </basic-container>
      <el-dialog title="标签列表" top="5vh" :visible.sync="diaPrintTab" width="500px">
        <div style="width:100%;height: 400px;overflow-y: auto;">
          <div id="qrCard" class="dia_body">
            <el-card class="box-card" v-for="(item, i) in qrData" :key="i" style="margin-bottom: 10px;">
              <el-row>
                <el-col :span="10" :offset="3">序号:</el-col>
                <el-col :span="10" style="font-weight: bold;">{{ i + 1 }}</el-col>
              </el-row>
              <el-row>
                <el-col :span="10" :offset="3">包装编号:</el-col>
                <el-col :span="10" style="font-weight: bold;">{{ item.packageNo }}</el-col>
              </el-row>
              <el-row>
                <el-col :span="10" :offset="3">包装台账二维码:</el-col>
                <el-col :span="10">
                  <vueQr :text="JSON.stringify(item)" :size="110" :margin="1"></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 { pagedata,dropById,list,saveList,deledata,sAuditstatus} from '@/api/quality/Packaging_ledger'
import ttable from '@/views/common/ztt-table.vue'
import packfrom from './pack-from.vue'
import packfromadd from './pack-fromadd.vue'
import vueQr from 'vue-qr'
import PrintJS from 'print-js'
export default {
    data(){
        return {
          qrData:[],
          diaPrintTab: false,
          multipleSelection: [],
          isCheck: false,
          dataway:{},
          goid:'',
          testStandardParams: [],
          packageBoxId:{},
            prelang: 'operation',
            dataListLoading: false,
            ajaxFun: pagedata,
            increase:false,
            addOrUpdateVisible:false,
            options: {
                height: 300, // 默认高度-为了表头固定
                stripe: true, // 是否为斑马纹 table
@@ -196,6 +195,7 @@
                lazy: false, // 是否需要懒加载
                fit: true, // 列的宽度是否自撑开
                multiSelect: true, //
                isEdit:false,
                seqNo: true,
                isShowHide: true, // 是否显示显影按钮
                isRefresh: true, // 是否显示刷新按钮
@@ -209,49 +209,41 @@
                data: [],
                // 标题
                column: [
                {
                  minWidth: 'code',
                  prop: 'state',
                  label: '状态',
                  sort: true,
                  isTrue: true,
                  isSearch: true,
                  searchInfoType: 'text'
                },
                  {
                    minWidth: '140',
                    prop: 'oo',
                    label: '订单编号',
                    prop: 'packageNo',
                    label: '包装编号',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },{
                    minWidth: '140',
                    prop: 'materhhooial',
                    label: '质量追溯号',
                    prop: 'createUser',
                    label: '创建人',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },{
                    minWidth: '140',
                    prop: 'contractNo',
                    label: '合同号',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },
                  {
                    minWidth: '140',
                    prop: 'mateuurial',
                    label: '产品名称',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },
                  {
                    minWidth: '140',
                    prop: 'materoiial',
                    label: '规格型号',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },
                  {
                    minWidth: '140',
                    prop: 'matperoial',
                    label: '单位',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
                  },
                  {
                    minWidth: '140',
                    prop: 'materpial',
                    label: '数量',
                    prop: 'updateUser',
                    label: '更新人',
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'text',
@@ -259,8 +251,18 @@
                  {
                    minWidth: '130',
                    width: '150',
                    prop: 'dealTime',
                    label: '入库时间',
                    prop: 'updateTime',
                    label: '更新日期',
                    sort: true,
                    isTrue: true,
                    isSearch: true,
                    searchInfoType: 'datetimerange',
                },
                {
                    minWidth: '130',
                    width: '150',
                    prop: 'createTime',
                    label: '创建日期',
                    sort: true,
                    isTrue: true,
                    isSearch: true,
@@ -268,20 +270,183 @@
                },
                ],
                toolbar: [
                  {
                    text: 'xxx',
                    type: 'primary',
                  },
                    {
                      text: '新增',
                      type: 'primary',
                      fun: this.addOrUpdateHandle
                    },
                    {
                      text: '标签打印',
                      type: 'primary',
                      fun: this.printLabel
                    },
                ],
                operator: [
                    {
                      text: '检验',
                      icon: 'el-icon-position',
                      type: 'text',
                      size: 'small',
                      fun: this.check
                    },{
                      text: '删除',
                      icon: 'el-icon-delete',
                      type: 'text',
                      size: 'small',
                      fun: this.deleteHandle
                    }
                  ],
                  operatorConfig: {
                    fixed: 'right',
                    label: '操作',
                    width: 120,
                    minWidth: 120
                  }
            },
       }
    },
    medthods: {},
//     computed: {
//     ...mapGetters(['permissions'])
//   },
    components: {
    ttable
      ttable,
      packfrom,
      packfromadd,
      vueQr
    },
    watch: {
      diaPrintTab(newVal){
        if(!newVal){
          this.qrData = []
        }
      }
    },
    methods: {
      //打印按钮
      printFun() {
          this.diaPrintTab = false;
          PrintJS({
              printable: 'qrCard',//页面
              type: "html",//文档类型
                maxWidth:450,
                targetStyles:['*'],
                style: `@page {
                  margin:0;
                  padding: 0;
                  size: 360px 170px;
                }
                html{
                  zoom:100%;
                }
                @media print{
                  width: 360px;
                  height: 170px;
                  margin:0;
                  padding: 0;
                }`,
                onPrintDialogClose: this.erexcel=false,
                targetStyles: ["*"], // 使用dom的所有样式,很重要
                font_size: '',
          });
      },
      handleSelectionChange(val){
        this.multipleSelection = val
        let lastRow = val[val.length - 1]
        this.handleCurrentChange(lastRow)
      },
      printLabel(){
        if(this.multipleSelection.length==0){
          this.$message.warning('请选择一条数据')
          return
        }
        this.diaPrintTab = true
        this.multipleSelection.forEach(item=>{
          let obj = {
            packageNo: item.packageNo,
            contractNo: item.contractNo,
            packageBoxId:item.id
          }
          this.qrData.push(obj)
        })
      },
       // 获取数据列表
      getData() {
        this.$refs.processconfiguration.refreshData()
      },
      wayRenovate(){
        this.getData()
      },
      //add
      addOrUpdateHandle(){
        this.addOrUpdateVisible = true
      },
      //删除
      deleteHandle(row){
        dropById({id:row.id}).then((res) =>{
          this.getData()
          this.$message.success('删除成功')
        })
      },
      handleCurrentChange(row){
        if(row.state=='已报检'){
          this.isCheck = true
        }
        this.dataway = row
        this.packageBoxId = {
          packageBoxId:row.id
        }
        this.goid = row.id
        this.rightquery()
      },
      rightquery(){
        list({packageBoxId:this.goid}).then((res) =>{
          this.testStandardParams = res.data.data
        })
      },
      //详情添加
      relateOperationParam(){
        if (this.dataway.state == "未报检") {
            this.increase = true
        }else{
          this.$message.error('请先选择包装项目')
        }
      },
      preserve(datalist){
        this.testStandardParams = datalist
      },
      //右边保存
      addpreserve(){
         this.testStandardParams.forEach(el => {
              el.packageBoxId =this.goid
         });
         console.log(this.testStandardParams);
  //       return
        saveList(this.testStandardParams).then((res) =>{
          if(res.status===200){
            this.$message.success('保存成功')
            this.rightquery()
          }
        }).catch(error=>{
          console.error(error);
        })
      },
      //删除
      deleteadd(row){
          deledata({id:row.id}).then((res)=>{
          this.$message.success('删除成功')
          this.rightquery()
          })
      },
      //审核
      check(row){
        let packageBox = {
                id:row.id,
                packageNo:row.packageNo,
                contractNo:row.contractNo,
                customerId:row.customerId,
        }
        sAuditstatus(packageBox).then((res) =>{
          this.getData()
          this.$message.success('检验成功')
        })
      },
    },
}
</script>