Mr.Zhang
2023-08-14 287934f48daa9889f824e12d1af687bc5aa3bbe2
web_standard/src/components/ext/OperaWorkorderDetailWindow.vue
@@ -1,28 +1,23 @@
<template>
  <GlobalWindow
    :title="title"
    width="1182px"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
  <GlobalWindow :title="title" width="1182px" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
    <div style="min-width:1150px">
      <el-form :model="form" ref="form" label-width="100px" label-suffix=":" inline>
        <div style="margin-bottom:15px">
          <span class="text-code">{{ form.procedureName + ' | ' + form.mmodel.name + ' ' + form.mmodel.code }}</span>
          <!-- 0已创建、1已备料、2已完工检、3已检验、4已报工、、6已取消 -->
          <span v-if="form.status==0" style="background-color: #305ED5;" class="status-log">已创建</span>
          <span v-else-if="form.status==6" style="background-color: #BBBBBB;" class="status-log">已取消</span>
          <span v-else style="background-color: #03AF76;" class="status-log">{{ form.status==1 ? '已备料' : form.status==2 ? '已完工检' : form.status==3 ? '已检验' : '已报工' }}</span>
          <span v-if="form.status == 0" style="background-color: #305ED5;" class="status-log">已创建</span>
          <span v-else-if="form.status == 6" style="background-color: #BBBBBB;" class="status-log">已取消</span>
          <span v-else style="background-color: #03AF76;" class="status-log">{{ form.status == 1 ? '已备料' : form.status == 2 ?
            '已完工检' : form.status == 3 ? '已检验' : '已报工' }}</span>
          <!-- <span v-if="form.status==3" style="background-color: #BBBBBB;" class="status-log">已取消</span> -->
        </div>
        <el-form-item label="工单编号" prop="workorderCode" class="count-style" >
        <el-form-item label="工单编号" prop="workorderCode" class="count-style">
          {{ form.code }}
        </el-form-item>
        <el-form-item label="生产日期" prop="proTime" class="count-style" >
        <el-form-item label="生产日期" prop="proTime" class="count-style">
          {{ form.planDate }}
        </el-form-item>
        <el-form-item label="生产批次号" prop="batch" class="count-style" >
        <el-form-item label="生产批次号" prop="batch" class="count-style">
          {{ form.batch }}
        </el-form-item>
        <!-- <el-form-item label="计划人员" prop="planUser" class="count-style" >
@@ -31,8 +26,8 @@
        <el-form-item label="计划日期" prop="planDate" class="count-style" >
          {{ form.pmodel.createTime }}
        </el-form-item> -->
        <el-form-item label="生产数量" prop="machine" class="count-style" >
          {{ form.planNum ? (form.planNum + (form.umodel.name ? form.umodel.name : '')) : '0'  }}
        <el-form-item label="生产数量" prop="machine" class="count-style">
          {{ form.planNum ? (form.planNum + (form.umodel.name ? form.umodel.name : '')) : '0' }}
        </el-form-item>
        <!-- <el-form-item label="计划数量" prop="planNum" class="count-style" >
          {{ form.pmodel.num }}
@@ -43,42 +38,36 @@
        <!-- <el-form-item label="发布日期" prop="startDate" class="count-style" >
          {{ form.pmodel.publishDate }}
        </el-form-item> -->
        <el-form-item label="原工单号" prop="originWorkorderId" class="count-style" >
        <el-form-item label="原工单号" prop="originWorkorderId" class="count-style">
          {{ form.originWorkorderId }}
        </el-form-item>
        <el-form-item label="分配人员" prop="distributeUser" class="count-style" >
        <el-form-item label="分配人员" prop="distributeUser" class="count-style">
          {{ form.userName }}
        </el-form-item>
        <el-form-item label="分配时间" prop="distributeTime" class="count-style" >
        <el-form-item label="分配时间" prop="distributeTime" class="count-style">
          {{ form.createTime }}
        </el-form-item>
        <el-form-item label="生产人员" prop="proUser" class="count-style" >
        <el-form-item label="生产人员" prop="proUser" class="count-style">
          <div v-for="(item, index) in form.proUserList" :key="index">{{ item.proUserDepartName }}</div>
          <!-- {{ form.proUserName + (form.proUserDepartName ? ('/' + form.proUserDepartName) : '') }} -->
        </el-form-item>
        <el-form-item label="生产设备" prop="machine" class="count-style" >
          {{ form.pgmodel && `【${form.pgmodel.code}】${form.pgmodel.name}`}}
        <el-form-item label="生产设备" prop="machine" class="count-style">
          {{ form.pgmodel && `【${form.pgmodel.code}】${form.pgmodel.name}` }}
        </el-form-item>
        <el-form-item label="合格数量" prop="qualifiedNum" class="count-style" >
        <el-form-item label="合格数量" prop="qualifiedNum" class="count-style">
          {{ form.qualifiedNum ? (form.qualifiedNum + (form.umodel.name ? form.umodel.name : '')) : '0' }}
        </el-form-item>
        <el-form-item label="不良数量" prop="unqualifiedNum" class="count-style" >
        <el-form-item label="不良数量" prop="unqualifiedNum" class="count-style">
          {{ form.unqualifiedNum ? (form.unqualifiedNum + (form.umodel.name ? form.umodel.name : '')) : '0' }}
        </el-form-item>
      </el-form>
      <!-- 表格和分页 -->
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="生产报工" name="first">
          <el-table
            v-loading="isSearch"
            :data="report"
            border
            show-summary
            :summary-method="getReportSummaries"
          >
          <!-- stripe -->
          <el-table v-loading="isSearch" :data="report" border show-summary :summary-method="getReportSummaries">
            <!-- stripe -->
            <el-table-column prop="createTime" label="报工时间" min-width="140px"></el-table-column>
            <el-table-column label="生产人员" show-overflow-tooltip min-width="100px">
              <template slot-scope="{row}">
@@ -86,11 +75,27 @@
              </template>
            </el-table-column>
            <el-table-column prop="machine" label="生产设备" min-width="100px">
              {{ form.pgmodel && `【${form.pgmodel.code}】${form.pgmodel.name}`}}
              {{ form.pgmodel && `【${form.pgmodel.code}】${form.pgmodel.name}` }}
            </el-table-column>
            <!-- <el-table-column prop="amodel.code" label="工装容器编号" show-overflow-tooltip="" min-width="100px"></el-table-column> -->
            <el-table-column prop="mmodel.name" label="物料名称" show-overflow-tooltip min-width="100px"></el-table-column>
            <el-table-column prop="doneType" label="报工类型" min-width="60px">
            <el-table-column prop="qualifiedNum" label="合格数量" min-width="100px">
              <template slot-scope="{row}">
                <span class="valid-style">{{ row.qualifiedNum + row.umodel.name }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="unqualifiedNum" label="不良数量" min-width="100px">
              <template slot-scope="{row}">
                <span class="unvalid-style">{{ row.unqualifiedNum + row.umodel.name }}</span>
                <!-- <span :class="row.materialDonetype==0 ? 'valid-style' : ''">{{ row.num + row.umodel.name }}</span> -->
              </template>
            </el-table-column>
            <el-table-column prop="num" label="报工数量" min-width="100px">
              <template slot-scope="{row}">
                <span>{{ row.num + row.umodel.name }}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="doneType" label="报工类型" min-width="60px">
              <template slot-scope="{row}">
                <span v-if="row.doneType==0" class="valid-style">合格</span>
                <span v-else-if="row.doneType==1" class="unvalid-style">不良</span>
@@ -102,15 +107,11 @@
              <template slot-scope="{row}">
                <span :class="row.doneType==0 ? 'valid-style' : (row.doneType==1 ? 'unvalid-style' :(row.doneType==2 ? 'scrap-style' : ''))">{{ row.num ? (row.num + (row.umodel.name ? row.umodel.name : '')) : '0' }}</span>
              </template>
            </el-table-column>
            </el-table-column> -->
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="生产检验" name="second">
          <el-table
            v-loading="isSearch"
            :data="verify"
            stripe
            border>
          <el-table v-loading="isSearch" :data="verify" stripe border>
            <el-table-column prop="code" label="检验记录编号" min-width="140px"></el-table-column>
            <el-table-column prop="createTime" label="检验时间" min-width="140px"></el-table-column>
            <el-table-column prop="smodelRealName" label="检验人员" min-width="100px"></el-table-column>
@@ -138,30 +139,23 @@
            </el-table-column>
            <el-table-column prop="devmodel.code" label="生产设备" min-width="100px">
              <template slot-scope="{row}">
                {{ row.devmodel && `【${row.devmodel.code}】${row.devmodel.name}`}}
                {{ row.devmodel && `【${row.devmodel.code}】${row.devmodel.name}` }}
              </template>
            </el-table-column>
            <!-- <el-table-column prop="proUserids" label="生产人员" show-overflow-tooltip min-width="100px"></el-table-column> -->
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="生产投料" name="third">
          <el-table
            v-loading="isSearch"
            :data="feeds"
            stripe
            border
            show-summary
            :summary-method="getPutSummaries"
          >
          <el-table v-loading="isSearch" :data="feeds" stripe border show-summary :summary-method="getPutSummaries">
            <el-table-column prop="createTime" label="投料时间" min-width="140px"></el-table-column>
            <!-- <el-table-column prop="amodel.code" label="工装容器编号" min-width="100px"></el-table-column> -->
            <el-table-column prop="mmodel.name" label="物料名称" min-width="100px"></el-table-column>
            <el-table-column prop="promodel.name" label="工序名称" min-width="100px"></el-table-column>
            <el-table-column label="质量属性" min-width="100px">
              <template slot-scope="{row}">
                <span v-if="row.materialDonetype==0" class="valid-style">合格</span>
                <span v-else-if="row.materialDonetype==1" class="unvalid-style">不良</span>
                <span v-else-if="row.materialDonetype==2" class="scrap-style">报废</span>
                <span v-if="row.materialDonetype == 0" class="valid-style">合格</span>
                <span v-else-if="row.materialDonetype == 1" class="unvalid-style">不良</span>
                <span v-else-if="row.materialDonetype == 2" class="scrap-style">报废</span>
                <span v-else>-</span>
              </template>
            </el-table-column>
@@ -178,12 +172,7 @@
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="生产点检" name="fourth">
          <el-table
            v-loading="isSearch"
            :data="check"
            stripe
            border
          >
          <el-table v-loading="isSearch" :data="check" stripe border>
            <el-table-column prop="createTime" label="记录时间" min-width="140px"></el-table-column>
            <el-table-column prop="userName" label="操作人员" min-width="100px"></el-table-column>
            <el-table-column prop="attrName" label="检点属性" min-width="100px"></el-table-column>
@@ -203,12 +192,8 @@
            <el-table-column prop="value" align="left"></el-table-column>
          </el-table> -->
        </el-tab-pane>
        <Pagination
          style="margin-top:10px"
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :pagination="pagination"
        ></Pagination>
        <Pagination style="margin-top:10px" @size-change="handleSizeChange" @current-change="handlePageChange"
          :pagination="pagination"></Pagination>
      </el-tabs>
    </div>
    <div slot="footer" class="window__header">
@@ -229,7 +214,7 @@
  name: 'OperaWorkorderDetailWindow',
  extends: BaseOpera,
  components: { GlobalWindow, Pagination },
  data () {
  data() {
    return {
      // 表单数据
      form: {
@@ -287,7 +272,7 @@
    }
  },
  inject: ['origins'],
  created () {
  created() {
    this.config({
      api: '/ext/materialExt',
      'field.id': 'id'
@@ -302,39 +287,39 @@
    //   })
  },
  methods: {
    open (title, target) {
    open(title, target) {
      this.title = title
      this.visible = true
      this.activeName = 'first',
      // 编辑
      this.$nextTick(() => {
        for (const key in this.form) {
          this.form[key] = target[key]
        }
        // console.log('this.form', this.form)
        workorderRecordExtPage(
          {
            capacity: this.pagination.pageSize,
            model: {
              type: 1,
              workorderId: this.form.id
            },
            page: this.pagination.pageIndex,
            sorts: null
          })
          .then(res => {
            // console.log(res)
            this.report = res.records
            this.pagination.pageIndex = res.page
            this.pagination.total = res.total
            this.pagination.pageSize = res.capacity
          })
          .catch(err => {
            console.log(err)
          })
      })
        // 编辑
        this.$nextTick(() => {
          for (const key in this.form) {
            this.form[key] = target[key]
          }
          // console.log('this.form', this.form)
          workorderRecordExtPage(
            {
              capacity: this.pagination.pageSize,
              model: {
                type: 1,
                workorderId: this.form.id
              },
              page: this.pagination.pageIndex,
              sorts: null
            })
            .then(res => {
              // console.log(res)
              this.report = res.records
              this.pagination.pageIndex = res.page
              this.pagination.total = res.total
              this.pagination.pageSize = res.capacity
            })
            .catch(err => {
              console.log(err)
            })
        })
    },
    cancel () {
    cancel() {
      this.$refs.form.resetFields()
      this.activeName = 'first'
      this.pagination.pageIndex = 1
@@ -342,21 +327,21 @@
      this.pagination.total = 0
      this.visible = false
    },
    statusToStr (status) {
    statusToStr(status) {
      for (const item of this.status) {
        if (item.id === status) {
          return item.name
        }
      }
    },
    originToStr (id) {
    originToStr(id) {
      for (const item of this.origins()) {
        if (item.id === id) {
          return item.code
        }
      }
    },
    columnStyle ({ row, column, rowIndex, columnIndex }) {
    columnStyle({ row, column, rowIndex, columnIndex }) {
      if (rowIndex % 2 === 0) {
        // 修改每行第一个单元格的背景色
        return 'background:#f3f6fc;'
@@ -364,22 +349,22 @@
        return 'background:#ffffff;'
      }
    },
    handleClick (tab, event) {
    handleClick(tab, event) {
      this.pagination.pageIndex = 1
      this.pagination.pageSize = 10
      this.pagination.total = 0
      this.search()
    },
    handleSizeChange (pageSize) {
    handleSizeChange(pageSize) {
      this.pagination.pageSize = pageSize
      this.search()
    },
    handlePageChange (pageIndex) {
    handlePageChange(pageIndex) {
      this.pagination.pageIndex = pageIndex
      // console.log('获取数据')
      this.search()
    },
    search () {
    search() {
      if (this.activeName === 'first') {
        workorderRecordExtPage(
          {
@@ -389,7 +374,7 @@
              workorderId: this.form.id
            },
            page: this.pagination.pageIndex,
            sorts: [{direction: "DESC", property: "CREATE_TIME"}]
            sorts: [{ direction: "DESC", property: "CREATE_TIME" }]
          })
          .then(res => {
            // console.log(res)
@@ -408,7 +393,7 @@
            workorderId: this.form.id
          },
          page: this.pagination.pageIndex,
          sorts: [{direction: "DESC", property: "CREATE_TIME"}]
          sorts: [{ direction: "DESC", property: "CREATE_TIME" }]
        })
          .then(res => {
            // console.log(res.records)
@@ -429,7 +414,7 @@
              workorderId: this.form.id
            },
            page: this.pagination.pageIndex,
            sorts: [{direction: "DESC", property: "CREATE_TIME"}]
            sorts: [{ direction: "DESC", property: "CREATE_TIME" }]
          })
          .then(res => {
            // console.log(res)
@@ -449,7 +434,7 @@
              workorderId: this.form.id
            },
            page: this.pagination.pageIndex,
            sorts: [{direction: "DESC", property: "CREATE_TIME"}]
            sorts: [{ direction: "DESC", property: "CREATE_TIME" }]
          })
          .then(res => {
            // console.log(res)
@@ -463,7 +448,7 @@
          })
      }
    },
    getPutSummaries (param) {
    getPutSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
@@ -476,7 +461,7 @@
        } else if (index === 5) {
          sums[index] = '-';
          return;
        }
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = 0
@@ -489,15 +474,12 @@
      });
      return sums
    },
    getReportSummaries (param) {
    getReportSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        } else if (index === 4) {
          sums[index] = '-';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
@@ -522,21 +504,24 @@
  width: 23%;
  // height: 32px;
}
::v-deep .el-form-item {
  margin-bottom: 8px !important;
}
.text-code {
  color: #333;
  font-weight: 500;
  padding-right: 15px;
  font-size: 15px;
  vertical-align:middle;
  vertical-align: middle;
}
.status-log {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color:#fff;
  vertical-align:middle;
  color: #fff;
  vertical-align: middle;
}
</style>