loulijun2021
2024-05-06 46528c3843ce67038ddb2e00dd3d3998c206a69e
src/views/mouldManager/mouldList.vue
@@ -3,7 +3,13 @@
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button v-waves type="success" icon="el-icon-download" @click="$router.push('./../systemSetting/dataImport?fileCode=12')">导入</el-button>
        <el-button
          v-waves
          type="success"
          icon="el-icon-download"
          @click="$router.push('./../systemSetting/dataImport?fileCode=12')"
        >导入
        </el-button>
        <!--        <el-button v-waves type="primary" icon="el-icon-download" @click="download">导出</el-button>-->
      </div>
@@ -129,7 +135,8 @@
            sortable="custom"
          >
            <template slot-scope="{row}">
              {{ onstateArr.find(i => parseFloat(i.code) === parseFloat(row.usestatus)).name }}
              {{ row.usestatus?onstateArr.find(i => parseFloat(i.code) === parseFloat(row.usestatus)).name:'/' }}
              <!--              {{ onstateArr.find(i => parseFloat(i.code) === parseFloat(row.usestatus)).name }}-->
            </template>
          </el-table-column>
          <el-table-column
@@ -155,30 +162,59 @@
            prop="warehousename"
            label="仓库名称"
            sortable="custom"
          />
          >
            <template slot-scope="{row}">
              {{ row.warehousename ? row.warehousename : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="surp_life"
            label="预计寿命"
            prop="location_name"
            label="库位名称"
            sortable="custom"
          />
          >
            <template slot-scope="{row}">
              {{ row.location_name ? row.location_name : '/' }}
            </template>
          </el-table-column>
          <el-table-column
            prop="is_part"
            label="产品关联"
            sortable="custom"
          >
            <template slot-scope="{row}">
              <el-tag v-if="row.is_part==='Y'" size="small" type="success">是</el-tag>
              <el-tag v-if="row.is_part==='N'" size="small" type="danger">否</el-tag>
              <!--              <el-tag v-if="row.is_part==='Y'" size="small" type="success">是</el-tag>-->
              <!--              <el-tag v-if="row.is_part==='N'" size="small" type="danger">否</el-tag>-->
              <i
                v-if="row.is_part==='Y'"
                :style="{color:$store.state.settings.theme}"
                class="el-icon-share"
                style="cursor: pointer"
                @click="connectClick(row)"
              />
              <i
                v-if="row.is_part==='N'"
                class="el-icon-share"
                style="color: rgb(180 ,181, 185);cursor:pointer;"
                @click="connectClick(row)"
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="surp_life"
            label="预计寿命(次)"
            width="125"
            sortable="custom"
          />
          <el-table-column
            prop="serlife"
            label="使用寿命"
            label="使用寿命(次)"
            width="125"
            sortable="custom"
          />
          <el-table-column
            prop="resi_life"
            label="剩余寿命"
            label="剩余寿命(次)"
            width="125"
            sortable="custom"
          />
          <el-table-column
@@ -215,6 +251,9 @@
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" :style="{color:$store.state.settings.theme}" @click="del(row)" />
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="履历" placement="top">
                  <i class="el-icon-view" :style="{color:$store.state.settings.theme}" style="cursor: pointer" @click="view(row)" />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
@@ -234,17 +273,25 @@
    <el-dialog
      v-el-drag-dialog
      :title="operation==='add'?'新增':'编辑'"
      :title="operation==='add'?'新增':(operation==='edit'?'编辑':'产品关联')"
      :visible.sync="dialogVisible"
      width="800px"
      :close-on-click-modal="false"
      top="7vh"
      :top="operation!=='connect'? '7vh':'15vh'"
      class="dialogFormClass"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" class="" inline :rules="dialogFormRules" :model="dialogForm" label-width="110px">
      <el-form
        v-if="operation!=='connect'"
        ref="dialogForm"
        class=""
        inline
        :rules="dialogFormRules"
        :model="dialogForm"
        label-width="110px"
      >
        <el-divider content-position="left">基本信息</el-divider>
        <el-form-item label="模具编码" prop="mouldcode">
          <el-input v-model="dialogForm.mouldcode" :disabled="operation!=='add'" style="width: 200px" />
@@ -256,13 +303,21 @@
          <el-input v-model="dialogForm.mouldspec" style="width: 200px" />
        </el-form-item>
        <el-form-item label="仓库信息" prop="warehousecode">
        <el-form-item required label="模具状态">
          <el-radio-group v-model="dialogForm.status">
            <el-radio label="Y">正常</el-radio>
            <el-radio label="N">故障</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="dialogForm.opertype==='Add'" prop="warehousecode" label="所属仓库">
          <el-select
            v-model="dialogForm.warehousecode"
            style="width:200px"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
            @change="warehousecodeChange"
          >
            <el-option
              v-for="item in wareHouseArr"
@@ -273,21 +328,33 @@
          </el-select>
        </el-form-item>
        <el-form-item label="预计寿命">
          <el-input v-model="dialogForm.surplife" style="width: 200px" />
        </el-form-item>
        <el-form-item label="剩余寿命">
          <el-input v-model="dialogForm.resilife" style="width: 200px" />
        <el-form-item v-if="dialogForm.opertype==='Add'" prop="location_code" label="所属库位">
          <el-select
            v-model="dialogForm.location_code"
            style="width:200px"
            :disabled="dialogForm.warehousecode===''"
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in locationArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item required label="使用状态">
          <el-radio-group v-model="dialogForm.status">
            <el-radio label="Y">正常</el-radio>
            <el-radio label="N">故障</el-radio>
          </el-radio-group>
        <el-form-item label="预计寿命(次)">
          <el-input v-model="dialogForm.surplife" oninput="value=value.replace(/[^0-9]/g,'')" style="width: 200px" />
        </el-form-item>
        <el-form-item label="剩余寿命(次)">
          <el-input v-model="dialogForm.resilife" oninput="value=value.replace(/[^0-9]/g,'')" style="width: 200px" />
        </el-form-item>
      </el-form>
      <el-divider content-position="left">关联产品</el-divider>
      <el-divider v-if="operation!=='connect'" content-position="left">关联产品</el-divider>
      <el-input
        v-model="filterText"
@@ -321,20 +388,162 @@
      </span>
    </el-dialog>
    <el-dialog
      v-el-drag-dialog
      title="履历查看"
      :visible.sync="dialogVisibleResume"
      width="1000px"
      :close-on-click-modal="false"
      top="7vh"
      class="dialogFormClass"
      @closed="handleCloseResume"
    >
      <div style="display: flex;justify-content: center;font-size: 18px;font-weight: bolder">模具在线信息查询</div>
      <el-descriptions class="margin-top" title=" " :column="3" size="size" border>
        <!--        <template slot="extra">-->
        <!--          <el-button type="primary" size="small">操作</el-button>-->
        <!--        </template>-->
        <el-descriptions-item>
          <template slot="label">
            <!--            <i class="el-icon-user" />-->
            模具编码
          </template>
          {{ formResume.mouldcode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            模具名称
          </template>
          {{ formResume.mouldname }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            规格型号
          </template>
          {{ formResume.mouldspec||'/' }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            模具状态
          </template>
          <!--          {{ formResume.status ==='Y'?'正常':'异常' }}-->
          <el-tag v-if="formResume.status==='Y'" size="small" type="success">正常</el-tag>
          <el-tag v-if="formResume.status==='N'" size="small" type="danger">故障</el-tag>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            使用状态
          </template>
          <!--          {{ formResume.usestatus }}-->
          {{ formResume.usestatus?onstateArr.find(i => parseFloat(i.code) === parseFloat(formResume.usestatus)).name:'/' }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            预计寿命(次)
          </template>
          {{ formResume.surp_life }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            剩余寿命(次)
          </template>
          {{ formResume.serlife }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            查看人员
          </template>
          {{ formResume.username }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            查看时间
          </template>
          {{ formResume.lm_date }}
        </el-descriptions-item>
      </el-descriptions>
      <div style="display: flex;justify-content: center;font-size: 18px;font-weight: bolder;margin: 20px 0">模具流转记录</div>
      <div class="elTableDiv">
        <el-table
          ref="tableDataRef2"
          class="tableFixed"
          :data="tableResume"
          height="370px"
          border
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:'370px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            prop="rowNum"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="opertype"
            label="操作类型"
          />
          <el-table-column
            prop="operusername"
            label="操作人员"
          />
          <el-table-column
            prop="operdate"
            label="操作时间"
          />
          <el-table-column
            prop="opertype"
            label="结果/对象"
          />
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="totalResume"
        :page.sync="formResume.page"
        :limit.sync="formResume.rows"
        align="right"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getMoldResumeSearch"
      />
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleResume=false">返 回</el-button>
          <!--          <el-button-->
          <!--            v-waves-->
          <!--            type="primary"-->
          <!--            :loading="$store.state.app.buttonIsDisabled"-->
          <!--            :disabled="$store.state.app.buttonIsDisabled"-->
          <!--            @click="dialogVisibleConfirm"-->
          <!--          >确 定</el-button>-->
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { handleDatetime, validateCode } from '@/utils/global'
import { handleDatetime, handleDatetime2, validateCode } from '@/utils/global'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import {
  ProductionScheduleReportExcelSearch,
  ProductionScheduleReportSearch
} from '@/api/ReportManager'
import { AddUpdateMouldManger, DeleteMouldManger, MouldMangerSearch } from '@/api/MouldManager'
import { InventoryTreePermissions, WareHouse } from '@/api/GeneralBasicData'
import { AddUpdateMouldManger, DeleteMouldManger, MoldResumeSearch, MouldMangerSearch } from '@/api/MouldManager'
import { InventoryTreePermissions, WareHouse, WareHouseSelectLocation } from '@/api/GeneralBasicData'
import arrayToTree from 'array-to-tree'
import { TCunstomerDelete } from '@/api/basicSettings'
@@ -359,7 +568,7 @@
        createuser: '', // 创建人员
        createdate: '', // 单据日期
        prop: 'code', // 排序字段
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
@@ -374,8 +583,11 @@
        { code: 1, name: '出库' },
        { code: 2, name: '上机' },
        { code: 3, name: '下机' },
        { code: 4, name: '维修' },
        { code: 5, name: '外借' }
        { code: 4, name: '待维修' },
        { code: 5, name: '已维修' },
        { code: 6, name: '已验证' },
        { code: 7, name: '外借' },
        { code: 8, name: '归还' }
      ],
      total: 10,
@@ -387,7 +599,8 @@
        mouldcode: '',
        mouldname: '',
        mouldspec: '',
        warehousecode: '',
        warehousecode: '', // 仓库编码
        location_code: '', // 库位编码
        surplife: '',
        resilife: '',
        status: 'Y',
@@ -403,6 +616,9 @@
        ],
        warehousecode: [
          { required: true, message: '请输入选择仓库信息', trigger: ['blur', 'change'] }
        ],
        location_code: [
          { required: true, message: '请输入选择库位信息', trigger: ['blur', 'change'] }
        ]
      },
      filterText: '',
@@ -417,7 +633,17 @@
        // }
      ],
      wareHouseArr: []
      wareHouseArr: [], // 仓库数组
      locationArr: [], // 库位数组
      dialogVisibleResume: false,
      formResume: {
        mouldcode: '',
        page: 1,
        rows: 20
      },
      tableResume: [],
      totalResume: 10
    }
  },
@@ -528,7 +754,10 @@
      this.form.createdate = ''
      this.getMouldMangerSearch()
    },
    async  warehousecodeChange(val) {
      const { data: res } = await WareHouseSelectLocation({ warhousecode: val })
      this.locationArr = res
    },
    add() {
      this.operation = 'add'
      this.dialogForm.opertype = 'Add'
@@ -544,6 +773,24 @@
        this.dialogForm.mouldname = row.name
        this.dialogForm.mouldspec = row.spec
        this.dialogForm.warehousecode = row.warehousecode
        this.dialogForm.location_code = row.location_code
        this.dialogForm.surplife = row.surp_life
        this.dialogForm.resilife = row.resi_life
        this.dialogForm.status = row.status
        this.dialogForm.mouldpart = row.partcode ? row.partcode.split(',') : []
        this.$refs.tree.setCheckedKeys(this.dialogForm.mouldpart)
      })
    },
    connectClick(row) {
      this.operation = 'connect'
      this.dialogVisible = true
      this.dialogForm.opertype = 'Update'
      this.$nextTick(() => {
        this.dialogForm.mouldcode = row.code
        this.dialogForm.mouldname = row.name
        this.dialogForm.mouldspec = row.spec
        // this.dialogForm.warehousecode = row.warehousecode
        this.dialogForm.surplife = row.surp_life
        this.dialogForm.resilife = row.resi_life
        this.dialogForm.status = row.status
@@ -567,52 +814,118 @@
        this.$notify.info('已取消删除')
      })
    },
    // 履历
    async view(row) {
      this.formResume.mouldcode = row.code
      this.formResume.mouldname = row.name
      this.formResume.mouldspec = row.spec
      this.formResume.username = localStorage.getItem('username')
      this.formResume.surp_life = row.surp_life
      this.formResume.serlife = row.serlife
      this.formResume.lm_date = handleDatetime2(new Date())
      this.formResume.status = row.status
      this.formResume.usestatus = row.usestatus
      await this.getMoldResumeSearch()
      this.dialogVisibleResume = true
      this.$nextTick(() => {
        this.$refs.tableDataRef2.doLayout()
      })
    },
    async getMoldResumeSearch() {
      const data = {
        mouldcode: this.formResume.mouldcode,
        createdate: '',
        page: this.formResume.page,
        rows: this.formResume.rows,
        prop: 'operdate',
        order: 'desc'
      }
      const res = await MoldResumeSearch(data)
      if (res.code === '200') {
        this.tableResume = res.data
        this.totalResume = res.count
      }
    },
    handleCloseResume() {
      this.tableResume = []
    },
    handleClose() {
      this.dialogForm = {
        mouldcode: '',
        mouldname: '',
        mouldspec: '',
        warehousecode: '',
        location_code: '',
        surplife: '',
        resilife: '',
        status: 'Y',
        mouldpart: '',
        opertype: ''
      }
      this.$refs.dialogForm.clearValidate()
      if (this.operation !== 'connect') {
        this.$refs.dialogForm.clearValidate()
      }
    },
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const checkData = this.$refs.tree.getCheckedNodes()
          this.dialogForm.mouldpart = []
          checkData.forEach(item => {
            if (!Object.keys(item).includes('children')) {
              this.dialogForm.mouldpart.push(item.code)
            }
          })
          if (this.dialogForm.mouldpart.length === 0) {
            return this.$message.info('关联产品不能为空!')
          }
          this.$store.state.app.buttonIsDisabled = true
          AddUpdateMouldManger(this.dialogForm).then(res => {
            if (res.code === '200') {
              this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.$refs.tree.setCheckedKeys([])
      if (this.operation !== 'connect') {
        this.$refs.dialogForm.validate(valid => {
          if (valid) {
            const checkData = this.$refs.tree.getCheckedNodes()
            this.dialogForm.mouldpart = []
            checkData.forEach(item => {
              if (!Object.keys(item).includes('children')) {
                this.dialogForm.mouldpart.push(item.code)
              }
            })
            // if (this.dialogForm.mouldpart.length === 0) {
            //   return this.$message.info('关联产品不能为空!')
            // }
            this.$store.state.app.buttonIsDisabled = true
            AddUpdateMouldManger(this.dialogForm).then(res => {
              if (res.code === '200') {
                this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
                this.$refs.tree.setCheckedKeys([])
              this.dialogVisible = false
              this.$store.state.app.buttonIsDisabled = false
              this.getMouldMangerSearch()
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
          })
        }
      })
                this.dialogVisible = false
                this.$store.state.app.buttonIsDisabled = false
                this.getMouldMangerSearch()
              } else {
                this.$store.state.app.buttonIsDisabled = false
                this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
              }
            })
          }
        })
      } else {
        const checkData = this.$refs.tree.getCheckedNodes()
        this.dialogForm.mouldpart = []
        checkData.forEach(item => {
          if (!Object.keys(item).includes('children')) {
            this.dialogForm.mouldpart.push(item.code)
          }
        })
        this.$store.state.app.buttonIsDisabled = true
        AddUpdateMouldManger(this.dialogForm).then(res => {
          if (res.code === '200') {
            this.$notify.success('关联成功!')
            this.$refs.tree.setCheckedKeys([])
            this.dialogVisible = false
            this.$store.state.app.buttonIsDisabled = false
            this.getMouldMangerSearch()
          } else {
            this.$store.state.app.buttonIsDisabled = false
            this.$notify.error('关联失败!')
          }
        })
      }
    },
    filterNode(value, data) {
      if (!value) return true