|
|
@@ -1,706 +1,706 @@
|
|
|
-<template>
|
|
|
- <div class="">
|
|
|
- <!-- 按钮功能 -->
|
|
|
- <div class="itemDiv">
|
|
|
- <span class="titleSmall">{{$t("prepare.common.tpJgroup")}}</span>
|
|
|
- <el-radio-group :disabled="showRadio" v-model="radio" @change="radioChange" style="margin-right: 15px;">
|
|
|
- <el-radio label="1">{{$t("prepare.common.idNeed.unneed")}}</el-radio>
|
|
|
- <el-radio label="2">{{$t("prepare.common.idNeed.reception")}}</el-radio>
|
|
|
- <el-radio label="3">{{$t("prepare.common.idNeed.need")}}</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- <!--<el-button :disabled="showButton" type="primary" icon="el-icon-plus" size="small" @click="add" circle></el-button>-->
|
|
|
- <el-button :disabled="showButton" type="primary" icon="el-icon-plus" size="small" @click="addTools" circle></el-button>
|
|
|
-<!-- <span style="margin-left: 50px;">-->
|
|
|
-<!-- <el-checkbox v-model="armTrayConf" :disabled="showRadio">{{$t("prepare.common.armTrayConf")}}</el-checkbox>-->
|
|
|
-<!-- <el-checkbox v-model="armFixtureConf" :disabled="showRadio">{{$t("prepare.common.armFixtureConf")}}</el-checkbox>-->
|
|
|
-<!-- </span>-->
|
|
|
- </div>
|
|
|
- <!-- Table数据 :span-method="objectSpanMethod" -->
|
|
|
- <el-table
|
|
|
- v-if="radio != '1'"
|
|
|
- ref="table"
|
|
|
- v-loading="loading"
|
|
|
- :data="tableData"
|
|
|
- border
|
|
|
- fit
|
|
|
- highlight-current-row
|
|
|
- @current-change="handleCurrentChange"
|
|
|
- style="width: 100%;"
|
|
|
- header-row-class-name="technologTable"
|
|
|
- >
|
|
|
- <!-- 编号 -->
|
|
|
- <el-table-column prop="no" :label='$t("prepare.table.toolGroup.no")' align="center" width="180px" :show-overflow-tooltip="true">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <div v-if="type == 'view'">{{row.no}}</div>
|
|
|
- <div v-else>
|
|
|
- <el-button type="text" @click="editTools(row)">{{row.no}}</el-button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <!-- 物料名称 -->
|
|
|
- <el-table-column prop="name" :label='$t("prepare.table.toolGroup.name")' align="center" width="120px" :show-overflow-tooltip="true"></el-table-column>
|
|
|
- <!-- 物料类型 -->
|
|
|
- <el-table-column prop="category.data" :label='$t("prepare.table.toolGroup.category")' width="150px"></el-table-column>
|
|
|
- <!-- 附件 -->
|
|
|
- <el-table-column prop="armorPic" :label='$t("prepare.table.toolGroup.armorPic")' align="center" width="180px">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <div v-if="row.jjImgList && row.jjImgList.length > 0" class="demo-image__preview">
|
|
|
- <el-image
|
|
|
- style="width: 100px; height: 60px"
|
|
|
- :src="row.jjImgList[0]"
|
|
|
- :preview-src-list="row.jjImgList">
|
|
|
- </el-image>
|
|
|
- </div>
|
|
|
- <el-button v-else type="text" @click="handleClick(row)">{{$t("common.uploadImg")}}</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <!-- 备注 -->
|
|
|
- <el-table-column prop="remark" :label='$t("common.remark")'>
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-input size="small" v-model="row.remark" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <!-- 操作 -->
|
|
|
- <el-table-column
|
|
|
- v-if="type != 'view' && radio != '2'"
|
|
|
- :label="$t('table.operation')"
|
|
|
- fixed="right"
|
|
|
- align="center"
|
|
|
- column-key="operation"
|
|
|
- width="60px"
|
|
|
- >
|
|
|
- <!--<template slot-scope="{ row }" v-if="row.category.key == '03'">-->
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <!--<el-tooltip class="item" :content='$t("common.edit")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-edit table-operation"
|
|
|
- style="color: #2db7f5;"
|
|
|
- @click="edit(row)"
|
|
|
- />
|
|
|
- </el-tooltip>-->
|
|
|
- <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-delete table-operation"
|
|
|
- style="color: #f50;"
|
|
|
- @click="domDelete(row)"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
-
|
|
|
- <pagination
|
|
|
- v-show="tableData.total > 0"
|
|
|
- :limit.sync="queryParams.size"
|
|
|
- :page.sync="queryParams.current"
|
|
|
- :total="Number(tableData.total)"
|
|
|
- @pagination="fetch"
|
|
|
- />
|
|
|
-
|
|
|
- <!-- 托盘 -->
|
|
|
- <tenant-add
|
|
|
- ref="add"
|
|
|
- :dialog-visible="dialogAdd.isVisible"
|
|
|
- :title="dialogAdd.title"
|
|
|
- @close="editAddClose"
|
|
|
- @success="editAddSuccess"
|
|
|
- />
|
|
|
-
|
|
|
- <!-- 夹具 -->
|
|
|
- <tenant-edit
|
|
|
- ref="edit"
|
|
|
- :dialog-visible="dialog.isVisible"
|
|
|
- :title="dialog.title"
|
|
|
- @close="editClose"
|
|
|
- @success="editSuccess"
|
|
|
- />
|
|
|
- <tenant-view
|
|
|
- ref="view"
|
|
|
- :dialog-visible="tenantViewVisible"
|
|
|
- @close="viewClose"
|
|
|
- />
|
|
|
-
|
|
|
- <!-- 上传图片对话框 -->
|
|
|
- <el-dialog
|
|
|
- title="上传图片"
|
|
|
- width="350px"
|
|
|
- :visible.sync="uploadQcVisible"
|
|
|
- :append-to-body="true"
|
|
|
- @closed="closePic"
|
|
|
- >
|
|
|
- <el-upload
|
|
|
- :key="timer"
|
|
|
- :headers="headers"
|
|
|
- :action="action"
|
|
|
- :data="fileOtherData"
|
|
|
- list-type="picture-card"
|
|
|
- :file-list="fileList"
|
|
|
- :on-remove="handleRemove"
|
|
|
- :on-success="handleSuccss"
|
|
|
- multiple
|
|
|
- :limit="1"
|
|
|
- >
|
|
|
- <i class="el-icon-plus" />
|
|
|
- </el-upload>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
- // 【新增】组件
|
|
|
- import TenantAdd from "./components/Add"
|
|
|
- // 【修改】组件
|
|
|
- import TenantEdit from "./components/Edit"
|
|
|
- // 【详情】组件
|
|
|
- import TenantView from "./components/View"
|
|
|
- // 【分页】组件
|
|
|
- import Pagination from "@/components/Pagination"
|
|
|
- // 【工艺管理】-API
|
|
|
- import technologyMgrApi from "@/api/prepareProductMgr/technologyMgr"
|
|
|
- // 共通的函数
|
|
|
- import { downloadFile, initEnums, initDicts, initQueryParams, arrReduce, arrSort } from '@/utils/commons'
|
|
|
- // 附件上传需要的组件和函数
|
|
|
- import db from "@/utils/localstorage";
|
|
|
- import {Base64} from 'js-base64';
|
|
|
-
|
|
|
- export default {
|
|
|
- name: "TrayForm",
|
|
|
- components: { Pagination, TenantAdd, TenantEdit, TenantView },
|
|
|
- props: {
|
|
|
- type: String,
|
|
|
- technology: Object
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- armTrayConf: false,
|
|
|
- armFixtureConf: false,
|
|
|
- currentRow: null, // 当前选中的数据
|
|
|
- uploadQcVisible: false, // 上传弹出框
|
|
|
- // 上传附件的参数
|
|
|
- timer: 1, // 生产图片的key,为了重载组件使用
|
|
|
- action: `${process.env.VUE_APP_BASE_API}/file/attachment/upload`, // 附件上传的API
|
|
|
- fileOtherData: { // 附件其它参数
|
|
|
- bizId: "",
|
|
|
- bizType: "TRAY"
|
|
|
- },
|
|
|
- fileList: [], // 附件的数据
|
|
|
- tempObj: {}, // 当前的Row数据
|
|
|
-
|
|
|
- radio: '3',
|
|
|
- audioStatus: [],
|
|
|
- dialogAdd: {
|
|
|
- isVisible: false,
|
|
|
- title: ""
|
|
|
- },
|
|
|
- dialog: {
|
|
|
- isVisible: false,
|
|
|
- title: ""
|
|
|
- },
|
|
|
- preview: {
|
|
|
- isVisible: false,
|
|
|
- context: ''
|
|
|
- },
|
|
|
- tenantViewVisible: false,
|
|
|
- tableKey: 0,
|
|
|
- queryParams: initQueryParams({}),
|
|
|
- selection: [],
|
|
|
- loading: false,
|
|
|
- tableData: [],
|
|
|
- spanArr: [], // 【组序】合并单元格
|
|
|
- spanArr2: [], // 【优先级】合并单元格
|
|
|
- }
|
|
|
- },
|
|
|
- // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
- created() {
|
|
|
- },
|
|
|
- /*watch: {
|
|
|
- radio: {
|
|
|
- handler: function(val) {
|
|
|
- // 如果是“来自上一工序”
|
|
|
- if(val && val == '2'){
|
|
|
- this.getPreMeterialList()
|
|
|
- }else{
|
|
|
- // 如果值存在
|
|
|
- if(val){
|
|
|
- // 清除数据
|
|
|
- this.tableData = []
|
|
|
- }
|
|
|
- }
|
|
|
- console.log("rdoo按钮:",val)
|
|
|
- }
|
|
|
- }
|
|
|
- },*/
|
|
|
- computed: {
|
|
|
- headers() {
|
|
|
- return {
|
|
|
- token: 'Bearer ' + db.get("TOKEN", ""),
|
|
|
- tenant: db.get("TENANT", "") || "",
|
|
|
- Authorization: `Basic ${Base64.encode(`${process.env.VUE_APP_CLIENT_ID}:${process.env.VUE_APP_CLIENT_SECRET}`)}`
|
|
|
- };
|
|
|
- },
|
|
|
- showRadio(){
|
|
|
- return this.type == "view" ? true : false
|
|
|
- },
|
|
|
- showButton(){
|
|
|
- let flag = false
|
|
|
- if(this.type == "view"){
|
|
|
- flag = true
|
|
|
- }else{
|
|
|
- flag = this.radio != '3' ? true : false
|
|
|
- }
|
|
|
- return flag
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- // 此时 data 已经被 observed 了
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 【Radio】按钮值变化-事件
|
|
|
- radioChange(val){
|
|
|
- // 提示用户,这样操作,会删除【程序】的数据。
|
|
|
- this.$message({
|
|
|
- message: '这样操作,会清空【程序】的所有数据!',
|
|
|
- type: 'warning'
|
|
|
- });
|
|
|
- // 如果是“来自上一工序”
|
|
|
- if(val == '2'){
|
|
|
- this.getPreMeterialList()
|
|
|
- }else{
|
|
|
- // 清除数据
|
|
|
- this.tableData = []
|
|
|
- }
|
|
|
- // 【托盘数据】一旦变化,【程序】必须清空数据,数据已经没有意义了
|
|
|
- this.$emit("clearProgram")
|
|
|
- },
|
|
|
- // 【托盘夹具组-来自上一工序】-函数
|
|
|
- getPreMeterialList(){
|
|
|
- technologyMgrApi.getPreProcedureTrayList(this.technology).then(res => {
|
|
|
- console.log("【托盘夹具组-来自上一工序】: ", res)
|
|
|
- res = res.data
|
|
|
- if(res.isSuccess){
|
|
|
- if(res.data){
|
|
|
- // 添加数据
|
|
|
- this.setDataMustSpan(this.setKeyList(res.data, 'tray'))
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 赋值前处理-添加key数据健
|
|
|
- setKeyList(list, flag){
|
|
|
- if(list && list.length > 0){
|
|
|
- let arr = []
|
|
|
- list.forEach(item => {
|
|
|
- // 添加唯一键
|
|
|
- item.key = ''+ Math.random()
|
|
|
- // 如果是托盘夹具的时候,组装分类
|
|
|
- if(flag == 'tray'){
|
|
|
- // 把【组序】和【优先级】改成字符串
|
|
|
- //item.groupSort = ''+ item.groupSort
|
|
|
- //item.groupPrority = ''+ item.groupPrority
|
|
|
- // 给图片一个列表数据,jjImgList
|
|
|
- item.jjImgList = []
|
|
|
- if(!!item.armorPic){
|
|
|
- item.jjImgList.push(item.armorPic)
|
|
|
- }
|
|
|
- // 添加类型
|
|
|
- /*if(item.bizType == '1'){
|
|
|
- item.category = {key: '03',data: '托盘'}
|
|
|
- }else{
|
|
|
- item.category = {key: '02',data: '夹具'}
|
|
|
- }*/
|
|
|
- }
|
|
|
- arr.push(item)
|
|
|
- })
|
|
|
- list = arr
|
|
|
- }else{
|
|
|
- list = []
|
|
|
- }
|
|
|
- return list
|
|
|
- },
|
|
|
-
|
|
|
- //获得数据相同的行数
|
|
|
- rowspanFiled(data, filed) {
|
|
|
- let spanArr5 = [];
|
|
|
- data.forEach((item,index) => {
|
|
|
- if( index === 0){
|
|
|
- spanArr5.push(1);
|
|
|
- this.position = 0;
|
|
|
- }else{
|
|
|
- if(data[index].groupSort === data[index-1].groupSort && data[index][filed] === data[index-1][filed]){
|
|
|
- spanArr5[this.position] += 1;
|
|
|
- spanArr5.push(0);
|
|
|
- }else{
|
|
|
- spanArr5.push(1);
|
|
|
- this.position = index;
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- return spanArr5;
|
|
|
- },
|
|
|
- //合并
|
|
|
- objectSpanMethod({ row, column, rowIndex, columnIndex }) { //表格合并行
|
|
|
- if (columnIndex === 0) {
|
|
|
- let _row = this.spanArr[rowIndex];
|
|
|
- let _col = _row > 0 ? 1 : 0;
|
|
|
- return {
|
|
|
- rowspan: _row,
|
|
|
- colspan: _col
|
|
|
- }
|
|
|
- }
|
|
|
- if(columnIndex === 1){
|
|
|
- let _row = this.spanArr2[rowIndex];
|
|
|
- let _col = _row > 0 ? 1 : 0;
|
|
|
- return {
|
|
|
- rowspan: _row,
|
|
|
- colspan: _col
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- //点击上传,打开对话框,此时暂存row数据
|
|
|
- handleClick(row){
|
|
|
- //打开对话框
|
|
|
- this.uploadQcVisible = true
|
|
|
- //定义全局变量接收row,row代表表格每一行的数据,每一行的row对象下边有一个jjImgList数组来存放上传的图片
|
|
|
- this.tempObj = row
|
|
|
- //判断row.jjImgList是否已经传过数据
|
|
|
- if(row.jjImgList.length !== 0){
|
|
|
- this.fileList = Object.assign([],row.jjImgList)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 上传成功,push到当前行的jjImgList数组中
|
|
|
- handleSuccss(res, file, fileList) {
|
|
|
- // console.log("图片:", res)
|
|
|
- // this.tempObj.jjImgList.push({ name: file.name, url: res.data.url, status: file.status, uid: file.uid })
|
|
|
- this.tempObj.jjImgList.push(res.data.url)
|
|
|
- console.log("图片数据:", this.tempObj.jjImgList)
|
|
|
- // 赋值图片
|
|
|
- this.tempObj.armorPic = res.data.url
|
|
|
- // 关闭对话框时
|
|
|
- this.uploadQcVisible = false
|
|
|
- this.closePic()
|
|
|
- },
|
|
|
-
|
|
|
- //关闭对话框时,重载组件,并且把fileList清空,否则会有异常
|
|
|
- closePic() {
|
|
|
- this.timer = new Date().getTime()
|
|
|
- this.fileList = []
|
|
|
- },
|
|
|
- // 移除图片
|
|
|
- handleRemove(file, fileList) {
|
|
|
- this.tempObj.jjImgList = Object.assign([], fileList)
|
|
|
- // 赋值图片
|
|
|
- this.tempObj.armorPic = ""
|
|
|
- },
|
|
|
- // 当Table换行的时候
|
|
|
- handleCurrentChange(val) {
|
|
|
- this.currentRow = val;
|
|
|
- },
|
|
|
- viewClose () {
|
|
|
- this.tenantViewVisible = false
|
|
|
- },
|
|
|
- onSelectChange (selection) {
|
|
|
- this.selection = selection
|
|
|
- },
|
|
|
- search () {
|
|
|
- this.fetch({
|
|
|
- ...this.queryParams
|
|
|
- })
|
|
|
- },
|
|
|
- reset () {
|
|
|
- this.queryParams = initQueryParams({})
|
|
|
- this.$refs.table.clearSort()
|
|
|
- this.$refs.table.clearFilter()
|
|
|
- this.search()
|
|
|
- },
|
|
|
-
|
|
|
- // 【删除】按钮-事件 groupSort
|
|
|
- domDelete(row){
|
|
|
- this.$confirm(this.$t("tips.comTips"), this.$t("common.tips"), {
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText: this.$t("common.confirm"),
|
|
|
- cancelButtonText: this.$t("common.cancel"),
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- // 过滤我们需要的数据
|
|
|
- let list = this.tableData.filter(item => {
|
|
|
- let f1 = item.id || item.key;
|
|
|
- let f2 = row.id || row.key;
|
|
|
- return f1 != f2
|
|
|
- });
|
|
|
- // 重新赋值
|
|
|
- this.tableData = list;
|
|
|
- }).catch(() => {})
|
|
|
- },
|
|
|
-
|
|
|
- // 【删除】按钮-事件 groupSort
|
|
|
- domDelete_v1(row){
|
|
|
- this.$confirm(this.$t("tips.comTips"), this.$t("common.tips"), {
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText: this.$t("common.confirm"),
|
|
|
- cancelButtonText: this.$t("common.cancel"),
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- // 过滤需要的数据
|
|
|
- let list = this.tableData.filter(item => item.groupSort != row.groupSort)
|
|
|
- // 重新赋值
|
|
|
- this.tableData = list
|
|
|
-
|
|
|
- // 要合并列的准备数据
|
|
|
- if(this.tableData.length > 0){
|
|
|
- this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
- this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
- }
|
|
|
-
|
|
|
- // 把值给父组件【程序】赋值
|
|
|
- this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
- }).catch(() => {})
|
|
|
- },
|
|
|
-
|
|
|
- // 托盘【新增】按钮-事件
|
|
|
- add () {
|
|
|
- // 设置【组序】
|
|
|
- if(this.tableData.length > 0){
|
|
|
- let groupSort = parseInt(this.tableData[this.tableData.length -1].groupSort) + 1
|
|
|
- this.$refs.add.tenant.groupSort = groupSort
|
|
|
- }
|
|
|
- this.$refs.add.setTenant(false)
|
|
|
- this.dialogAdd.title = this.$t("common.add") + this.$t("prepare.common.tpJgroup")
|
|
|
- this.dialogAdd.isVisible = true
|
|
|
- },
|
|
|
-
|
|
|
- // 托盘【修改】按钮-事件
|
|
|
- addRow(row){
|
|
|
- // 设置【组序】
|
|
|
- this.$refs.add.tenant.groupSort = parseInt(row.groupSort)
|
|
|
- this.$refs.add.setTenant(row)
|
|
|
- this.dialogAdd.title = this.$t("common.edit") + this.$t("prepare.common.tpJgroup")
|
|
|
- this.dialogAdd.isVisible = true
|
|
|
- },
|
|
|
-
|
|
|
- // 弹出框【取消】按钮-事件
|
|
|
- editAddClose () {
|
|
|
- this.dialogAdd.isVisible = false
|
|
|
- },
|
|
|
-
|
|
|
- // 弹出框【确定】按钮-事件
|
|
|
- editAddSuccess (arr) {
|
|
|
- // 通过深层复制,避免相同地址引起数据,一起改变
|
|
|
- arr = JSON.parse(arr)
|
|
|
- // 需要处理的最终数据
|
|
|
- let list = []
|
|
|
- // 把【新增-托盘】的对象信息拿出来,
|
|
|
- let addObj = arr.filter(item => item.category.key == '03')[0]
|
|
|
- // console.log("托盘夹具数据:", arr, addObj)
|
|
|
- // 和已经有的数据,进行对比过滤
|
|
|
- if(this.tableData.length > 0){
|
|
|
- let isFlag = false; // 默认【托盘不存在】
|
|
|
- // 已经存在的【托盘】的分组
|
|
|
- let groupSort = ""
|
|
|
- this.tableData.map(item => {
|
|
|
- // 如果数据已经存在
|
|
|
- if(item.trayId == addObj.trayId){
|
|
|
- // console.log("wwwww :", item, addObj)
|
|
|
- groupSort = item.groupSort
|
|
|
- isFlag = true
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
- // 如果存在,就比较。或者干脆全部删除
|
|
|
- if(isFlag){
|
|
|
- // console.log("【托盘】的分组groupSort: ", groupSort)
|
|
|
- // 过滤已经存在的【托盘】分组数据
|
|
|
- let target = this.tableData.filter(item => item.groupSort != groupSort)
|
|
|
- // 合并数据
|
|
|
- list = [...target, ...arr]
|
|
|
- // console.log("【托盘】的分组2222: ", list)
|
|
|
- }else{
|
|
|
- // 合并当前数组,和新增的数组
|
|
|
- list = [...this.tableData, ...arr]
|
|
|
- }
|
|
|
- // 进行排序
|
|
|
- list = arrSort(list,"groupSort")
|
|
|
- // 赋值
|
|
|
- this.tableData = list
|
|
|
- // console.log("最终数据:", list)
|
|
|
- }else{
|
|
|
- // 直接赋值
|
|
|
- this.tableData = arr
|
|
|
- }
|
|
|
- // 要合并列的准备数据
|
|
|
- if(this.tableData.length > 0){
|
|
|
- this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
- this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
- }
|
|
|
- // 把值给父组件【程序】赋值
|
|
|
- this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
- },
|
|
|
-
|
|
|
- // 设置数据前,需要合并
|
|
|
- setDataMustSpan(data){
|
|
|
- this.tableData = data
|
|
|
- // 要合并列的准备数据
|
|
|
- if(data.length > 0){
|
|
|
- this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
- this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
- // 把值给父组件【程序】赋值
|
|
|
- this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 【夹具】新增-事件
|
|
|
- addTools(){
|
|
|
- this.$refs.edit.type = "add";
|
|
|
- this.dialog.title = this.$t("common.add") + this.$t("prepare.common.tab5");
|
|
|
- this.dialog.isVisible = true;
|
|
|
- },
|
|
|
-
|
|
|
- // 【夹具】修改-事件
|
|
|
- editTools(row){
|
|
|
- this.dialog.title = this.$t("common.edit") + this.$t("prepare.common.tab5");
|
|
|
- this.$refs.edit.type = "edit";
|
|
|
- // 赋值,修改的识别用。
|
|
|
- let keys = row.id || row.key;
|
|
|
- this.$refs.edit.keys = keys;
|
|
|
- this.dialog.isVisible = true;
|
|
|
- },
|
|
|
-
|
|
|
- editClose(){
|
|
|
- this.dialog.isVisible = false
|
|
|
- },
|
|
|
-
|
|
|
- editSuccess(data, type){
|
|
|
- // 最新数组
|
|
|
- let list = []
|
|
|
- // 深度Copy,防止翻车
|
|
|
- let tool = JSON.parse(data);
|
|
|
- let item = {
|
|
|
- key: tool.key, // 关键字
|
|
|
- trayPositionId: tool.id,
|
|
|
- trayId: tool.trayId, // 夹具id
|
|
|
- no: tool.no, // 编号
|
|
|
- name: tool.name, // 名称
|
|
|
- brand: tool.brand, // 品牌
|
|
|
- category: tool.category // 物料类型
|
|
|
- };
|
|
|
- if (type == "add") {
|
|
|
- // 添加,附件
|
|
|
- item.jjImgList = [];
|
|
|
- // 添加数据
|
|
|
- list.push(item);
|
|
|
- // 重新赋值
|
|
|
- this.tableData = [...this.tableData, ...list];
|
|
|
- } else {
|
|
|
- let target = [];
|
|
|
- this.tableData.map(obj => {
|
|
|
- let f1 = obj.id;
|
|
|
- let f2 = tool.key;
|
|
|
- if(f1 == f2){
|
|
|
- obj.trayPositionId = tool.id;
|
|
|
- obj.trayId = tool.trayId; // 夹具id
|
|
|
- obj.no = tool.no; // 编号
|
|
|
- obj.name = tool.name; // 名称
|
|
|
- obj.brand = tool.brand; // 品牌
|
|
|
- obj.category = tool.category; // 物料类型
|
|
|
- obj.jjImgList = []; // 附件
|
|
|
- }
|
|
|
- target.push(obj);
|
|
|
- });
|
|
|
- // 赋值
|
|
|
- this.tableData = target;
|
|
|
- console.log("最终数据:", this.tableData);
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- editSuccess_v1(obj){
|
|
|
- // 深度Copy,防止翻车
|
|
|
- let tool = JSON.parse(obj)
|
|
|
- // console.log("选择的对象:", tool)
|
|
|
- // console.log("当前选中的对象:", this.currentRow)
|
|
|
- // 最新数组
|
|
|
- let list = []
|
|
|
- this.tableData.map(item => {
|
|
|
- if(item.key == this.currentRow.key){
|
|
|
- item.trayPositionId = tool.id
|
|
|
- // 夹具id
|
|
|
- item.trayId = tool.trayId,
|
|
|
- item.no = tool.no // 编号
|
|
|
- item.name = tool.name // 名称
|
|
|
- item.brand = tool.brand // 品牌
|
|
|
- }
|
|
|
- // 添加数据
|
|
|
- list.push(item)
|
|
|
- })
|
|
|
- // 重新赋值
|
|
|
- this.tableData = list
|
|
|
- },
|
|
|
-
|
|
|
- clearSelections () {
|
|
|
- this.$refs.table.clearSelection()
|
|
|
- },
|
|
|
- delete (ids) {
|
|
|
-
|
|
|
- },
|
|
|
- view (row) {
|
|
|
- this.$refs.view.setTenant(row)
|
|
|
- this.tenantViewVisible = true
|
|
|
- },
|
|
|
- // 【修改】表头上Btn-事件
|
|
|
- editOne() {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.noDataSelected"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.selection.length > 1) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.mustOne"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- this.edit(this.selection[0]);
|
|
|
- },
|
|
|
- edit (row) {
|
|
|
- if (row.readonly) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.systemData"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- this.$refs.edit.setTenant(row)
|
|
|
- this.$refs.edit.type = "edit"
|
|
|
- this.dialog.title = this.$t("common.edit")
|
|
|
- this.dialog.isVisible = true
|
|
|
- },
|
|
|
- fetch (params = {}) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-</script>
|
|
|
-<style>
|
|
|
-</style>
|
|
|
-<style lang="scss" scoped>
|
|
|
- .titleSmall{
|
|
|
- position: relative;
|
|
|
- padding-left: 10px;
|
|
|
- margin-right: 15px;
|
|
|
- }
|
|
|
- .titleSmall:before{
|
|
|
- content: '';
|
|
|
- position: absolute;
|
|
|
- background: #1890ff;
|
|
|
- width: 5px;
|
|
|
- height: 90%;
|
|
|
- left: 0;
|
|
|
- top: 1px;
|
|
|
- }
|
|
|
- .itemDiv{
|
|
|
- margin: 10px 0;
|
|
|
- }
|
|
|
-</style>
|
|
|
+<template>
|
|
|
+ <div class="">
|
|
|
+ <!-- 按钮功能 -->
|
|
|
+ <div class="itemDiv">
|
|
|
+ <span class="titleSmall">{{$t("prepare.common.tpJgroup")}}</span>
|
|
|
+ <el-radio-group :disabled="showRadio" v-model="radio" @change="radioChange" style="margin-right: 15px;">
|
|
|
+ <el-radio label="1">{{$t("prepare.common.idNeed.unneed")}}</el-radio>
|
|
|
+ <el-radio label="2">{{$t("prepare.common.idNeed.reception")}}</el-radio>
|
|
|
+ <el-radio label="3">{{$t("prepare.common.idNeed.need")}}</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ <!--<el-button :disabled="showButton" type="primary" icon="el-icon-plus" size="small" @click="add" circle></el-button>-->
|
|
|
+ <el-button :disabled="showButton" type="primary" icon="el-icon-plus" size="small" @click="addTools" circle></el-button>
|
|
|
+<!-- <span style="margin-left: 50px;">-->
|
|
|
+<!-- <el-checkbox v-model="armTrayConf" :disabled="showRadio">{{$t("prepare.common.armTrayConf")}}</el-checkbox>-->
|
|
|
+<!-- <el-checkbox v-model="armFixtureConf" :disabled="showRadio">{{$t("prepare.common.armFixtureConf")}}</el-checkbox>-->
|
|
|
+<!-- </span>-->
|
|
|
+ </div>
|
|
|
+ <!-- Table数据 :span-method="objectSpanMethod" -->
|
|
|
+ <el-table
|
|
|
+ v-if="radio != '1'"
|
|
|
+ ref="table"
|
|
|
+ v-loading="loading"
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ highlight-current-row
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ style="width: 100%;"
|
|
|
+ header-row-class-name="technologTable"
|
|
|
+ >
|
|
|
+ <!-- 编号 -->
|
|
|
+ <el-table-column prop="no" :label='$t("prepare.table.toolGroup.no")' align="center" width="180px" :show-overflow-tooltip="true">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <div v-if="type == 'view'">{{row.no}}</div>
|
|
|
+ <div v-else>
|
|
|
+ <el-button type="text" @click="editTools(row)">{{row.no}}</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 物料名称 -->
|
|
|
+ <el-table-column prop="name" :label='$t("prepare.table.toolGroup.name")' align="center" width="120px" :show-overflow-tooltip="true"></el-table-column>
|
|
|
+ <!-- 物料类型 -->
|
|
|
+ <el-table-column prop="category.data" :label='$t("prepare.table.toolGroup.category")' width="150px"></el-table-column>
|
|
|
+ <!-- 附件 -->
|
|
|
+ <el-table-column prop="armorPic" :label='$t("prepare.table.toolGroup.armorPic")' align="center" width="180px">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <div v-if="row.jjImgList && row.jjImgList.length > 0" class="demo-image__preview">
|
|
|
+ <el-image
|
|
|
+ style="width: 100px; height: 60px"
|
|
|
+ :src="row.jjImgList[0]"
|
|
|
+ :preview-src-list="row.jjImgList">
|
|
|
+ </el-image>
|
|
|
+ </div>
|
|
|
+ <el-button v-else type="text" @click="handleClick(row)">{{$t("common.uploadImg")}}</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 备注 -->
|
|
|
+ <el-table-column prop="remark" :label='$t("common.remark")'>
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input size="small" v-model="row.remark" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 操作 -->
|
|
|
+ <el-table-column
|
|
|
+ v-if="type != 'view' && radio != '2'"
|
|
|
+ :label="$t('table.operation')"
|
|
|
+ fixed="right"
|
|
|
+ align="center"
|
|
|
+ column-key="operation"
|
|
|
+ width="60px"
|
|
|
+ >
|
|
|
+ <!--<template slot-scope="{ row }" v-if="row.category.key == '03'">-->
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <!--<el-tooltip class="item" :content='$t("common.edit")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-edit table-operation"
|
|
|
+ style="color: #2db7f5;"
|
|
|
+ @click="edit(row)"
|
|
|
+ />
|
|
|
+ </el-tooltip>-->
|
|
|
+ <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete table-operation"
|
|
|
+ style="color: #f50;"
|
|
|
+ @click="domDelete(row)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="tableData.total > 0"
|
|
|
+ :limit.sync="queryParams.size"
|
|
|
+ :page.sync="queryParams.current"
|
|
|
+ :total="Number(tableData.total)"
|
|
|
+ @pagination="fetch"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 托盘 -->
|
|
|
+ <tenant-add
|
|
|
+ ref="add"
|
|
|
+ :dialog-visible="dialogAdd.isVisible"
|
|
|
+ :title="dialogAdd.title"
|
|
|
+ @close="editAddClose"
|
|
|
+ @success="editAddSuccess"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 夹具 -->
|
|
|
+ <tenant-edit
|
|
|
+ ref="edit"
|
|
|
+ :dialog-visible="dialog.isVisible"
|
|
|
+ :title="dialog.title"
|
|
|
+ @close="editClose"
|
|
|
+ @success="editSuccess"
|
|
|
+ />
|
|
|
+ <tenant-view
|
|
|
+ ref="view"
|
|
|
+ :dialog-visible="tenantViewVisible"
|
|
|
+ @close="viewClose"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 上传图片对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="上传图片"
|
|
|
+ width="350px"
|
|
|
+ :visible.sync="uploadQcVisible"
|
|
|
+ :append-to-body="true"
|
|
|
+ @closed="closePic"
|
|
|
+ >
|
|
|
+ <el-upload
|
|
|
+ :key="timer"
|
|
|
+ :headers="headers"
|
|
|
+ :action="action"
|
|
|
+ :data="fileOtherData"
|
|
|
+ list-type="picture-card"
|
|
|
+ :file-list="fileList"
|
|
|
+ :on-remove="handleRemove"
|
|
|
+ :on-success="handleSuccss"
|
|
|
+ multiple
|
|
|
+ :limit="1"
|
|
|
+ >
|
|
|
+ <i class="el-icon-plus" />
|
|
|
+ </el-upload>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ // 【新增】组件
|
|
|
+ import TenantAdd from "./components/Add"
|
|
|
+ // 【修改】组件
|
|
|
+ import TenantEdit from "./components/Edit"
|
|
|
+ // 【详情】组件
|
|
|
+ import TenantView from "./components/View"
|
|
|
+ // 【分页】组件
|
|
|
+ import Pagination from "@/components/Pagination"
|
|
|
+ // 【工艺管理】-API
|
|
|
+ import technologyMgrApi from "@/api/prepareProductMgr/technologyMgr"
|
|
|
+ // 共通的函数
|
|
|
+ import { downloadFile, initEnums, initDicts, initQueryParams, arrReduce, arrSort } from '@/utils/commons'
|
|
|
+ // 附件上传需要的组件和函数
|
|
|
+ import db from "@/utils/localstorage";
|
|
|
+ import {Base64} from 'js-base64';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: "TrayForm",
|
|
|
+ components: { Pagination, TenantAdd, TenantEdit, TenantView },
|
|
|
+ props: {
|
|
|
+ type: String,
|
|
|
+ technology: Object
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ armTrayConf: false,
|
|
|
+ armFixtureConf: false,
|
|
|
+ currentRow: null, // 当前选中的数据
|
|
|
+ uploadQcVisible: false, // 上传弹出框
|
|
|
+ // 上传附件的参数
|
|
|
+ timer: 1, // 生产图片的key,为了重载组件使用
|
|
|
+ action: `${process.env.VUE_APP_BASE_API}/file/attachment/upload`, // 附件上传的API
|
|
|
+ fileOtherData: { // 附件其它参数
|
|
|
+ bizId: "",
|
|
|
+ bizType: "TRAY"
|
|
|
+ },
|
|
|
+ fileList: [], // 附件的数据
|
|
|
+ tempObj: {}, // 当前的Row数据
|
|
|
+
|
|
|
+ radio: '3',
|
|
|
+ audioStatus: [],
|
|
|
+ dialogAdd: {
|
|
|
+ isVisible: false,
|
|
|
+ title: ""
|
|
|
+ },
|
|
|
+ dialog: {
|
|
|
+ isVisible: false,
|
|
|
+ title: ""
|
|
|
+ },
|
|
|
+ preview: {
|
|
|
+ isVisible: false,
|
|
|
+ context: ''
|
|
|
+ },
|
|
|
+ tenantViewVisible: false,
|
|
|
+ tableKey: 0,
|
|
|
+ queryParams: initQueryParams({}),
|
|
|
+ selection: [],
|
|
|
+ loading: false,
|
|
|
+ tableData: [],
|
|
|
+ spanArr: [], // 【组序】合并单元格
|
|
|
+ spanArr2: [], // 【优先级】合并单元格
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
+ created() {
|
|
|
+ },
|
|
|
+ /*watch: {
|
|
|
+ radio: {
|
|
|
+ handler: function(val) {
|
|
|
+ // 如果是“来自上一工序”
|
|
|
+ if(val && val == '2'){
|
|
|
+ this.getPreMeterialList()
|
|
|
+ }else{
|
|
|
+ // 如果值存在
|
|
|
+ if(val){
|
|
|
+ // 清除数据
|
|
|
+ this.tableData = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log("rdoo按钮:",val)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },*/
|
|
|
+ computed: {
|
|
|
+ headers() {
|
|
|
+ return {
|
|
|
+ token: 'Bearer ' + db.get("TOKEN", ""),
|
|
|
+ tenant: db.get("TENANT", "") || "",
|
|
|
+ Authorization: `Basic ${Base64.encode(`${process.env.VUE_APP_CLIENT_ID}:${process.env.VUE_APP_CLIENT_SECRET}`)}`
|
|
|
+ };
|
|
|
+ },
|
|
|
+ showRadio(){
|
|
|
+ return this.type == "view" ? true : false
|
|
|
+ },
|
|
|
+ showButton(){
|
|
|
+ let flag = false
|
|
|
+ if(this.type == "view"){
|
|
|
+ flag = true
|
|
|
+ }else{
|
|
|
+ flag = this.radio != '3' ? true : false
|
|
|
+ }
|
|
|
+ return flag
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ // 此时 data 已经被 observed 了
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 【Radio】按钮值变化-事件
|
|
|
+ radioChange(val){
|
|
|
+ // 提示用户,这样操作,会删除【程序】的数据。
|
|
|
+ this.$message({
|
|
|
+ message: '这样操作,会清空【程序】的所有数据!',
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ // 如果是“来自上一工序”
|
|
|
+ if(val == '2'){
|
|
|
+ this.getPreMeterialList()
|
|
|
+ }else{
|
|
|
+ // 清除数据
|
|
|
+ this.tableData = []
|
|
|
+ }
|
|
|
+ // 【托盘数据】一旦变化,【程序】必须清空数据,数据已经没有意义了
|
|
|
+ this.$emit("clearProgram")
|
|
|
+ },
|
|
|
+ // 【托盘夹具组-来自上一工序】-函数
|
|
|
+ getPreMeterialList(){
|
|
|
+ technologyMgrApi.getPreProcedureTrayList(this.technology).then(res => {
|
|
|
+ console.log("【托盘夹具组-来自上一工序】: ", res)
|
|
|
+ res = res.data
|
|
|
+ if(res.isSuccess){
|
|
|
+ if(res.data){
|
|
|
+ // 添加数据
|
|
|
+ this.setDataMustSpan(this.setKeyList(res.data, 'tray'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 赋值前处理-添加key数据健
|
|
|
+ setKeyList(list, flag){
|
|
|
+ if(list && list.length > 0){
|
|
|
+ let arr = []
|
|
|
+ list.forEach(item => {
|
|
|
+ // 添加唯一键
|
|
|
+ item.key = ''+ Math.random()
|
|
|
+ // 如果是托盘夹具的时候,组装分类
|
|
|
+ if(flag == 'tray'){
|
|
|
+ // 把【组序】和【优先级】改成字符串
|
|
|
+ //item.groupSort = ''+ item.groupSort
|
|
|
+ //item.groupPrority = ''+ item.groupPrority
|
|
|
+ // 给图片一个列表数据,jjImgList
|
|
|
+ item.jjImgList = []
|
|
|
+ if(!!item.armorPic){
|
|
|
+ item.jjImgList.push(item.armorPic)
|
|
|
+ }
|
|
|
+ // 添加类型
|
|
|
+ /*if(item.bizType == '1'){
|
|
|
+ item.category = {key: '03',data: '托盘'}
|
|
|
+ }else{
|
|
|
+ item.category = {key: '02',data: '夹具'}
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ arr.push(item)
|
|
|
+ })
|
|
|
+ list = arr
|
|
|
+ }else{
|
|
|
+ list = []
|
|
|
+ }
|
|
|
+ return list
|
|
|
+ },
|
|
|
+
|
|
|
+ //获得数据相同的行数
|
|
|
+ rowspanFiled(data, filed) {
|
|
|
+ let spanArr5 = [];
|
|
|
+ data.forEach((item,index) => {
|
|
|
+ if( index === 0){
|
|
|
+ spanArr5.push(1);
|
|
|
+ this.position = 0;
|
|
|
+ }else{
|
|
|
+ if(data[index].groupSort === data[index-1].groupSort && data[index][filed] === data[index-1][filed]){
|
|
|
+ spanArr5[this.position] += 1;
|
|
|
+ spanArr5.push(0);
|
|
|
+ }else{
|
|
|
+ spanArr5.push(1);
|
|
|
+ this.position = index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return spanArr5;
|
|
|
+ },
|
|
|
+ //合并
|
|
|
+ objectSpanMethod({ row, column, rowIndex, columnIndex }) { //表格合并行
|
|
|
+ if (columnIndex === 0) {
|
|
|
+ let _row = this.spanArr[rowIndex];
|
|
|
+ let _col = _row > 0 ? 1 : 0;
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(columnIndex === 1){
|
|
|
+ let _row = this.spanArr2[rowIndex];
|
|
|
+ let _col = _row > 0 ? 1 : 0;
|
|
|
+ return {
|
|
|
+ rowspan: _row,
|
|
|
+ colspan: _col
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //点击上传,打开对话框,此时暂存row数据
|
|
|
+ handleClick(row){
|
|
|
+ //打开对话框
|
|
|
+ this.uploadQcVisible = true
|
|
|
+ //定义全局变量接收row,row代表表格每一行的数据,每一行的row对象下边有一个jjImgList数组来存放上传的图片
|
|
|
+ this.tempObj = row
|
|
|
+ //判断row.jjImgList是否已经传过数据
|
|
|
+ if(row.jjImgList.length !== 0){
|
|
|
+ this.fileList = Object.assign([],row.jjImgList)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上传成功,push到当前行的jjImgList数组中
|
|
|
+ handleSuccss(res, file, fileList) {
|
|
|
+ // console.log("图片:", res)
|
|
|
+ // this.tempObj.jjImgList.push({ name: file.name, url: res.data.url, status: file.status, uid: file.uid })
|
|
|
+ this.tempObj.jjImgList.push(res.data.url)
|
|
|
+ console.log("图片数据:", this.tempObj.jjImgList)
|
|
|
+ // 赋值图片
|
|
|
+ this.tempObj.armorPic = res.data.url
|
|
|
+ // 关闭对话框时
|
|
|
+ this.uploadQcVisible = false
|
|
|
+ this.closePic()
|
|
|
+ },
|
|
|
+
|
|
|
+ //关闭对话框时,重载组件,并且把fileList清空,否则会有异常
|
|
|
+ closePic() {
|
|
|
+ this.timer = new Date().getTime()
|
|
|
+ this.fileList = []
|
|
|
+ },
|
|
|
+ // 移除图片
|
|
|
+ handleRemove(file, fileList) {
|
|
|
+ this.tempObj.jjImgList = Object.assign([], fileList)
|
|
|
+ // 赋值图片
|
|
|
+ this.tempObj.armorPic = ""
|
|
|
+ },
|
|
|
+ // 当Table换行的时候
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.currentRow = val;
|
|
|
+ },
|
|
|
+ viewClose () {
|
|
|
+ this.tenantViewVisible = false
|
|
|
+ },
|
|
|
+ onSelectChange (selection) {
|
|
|
+ this.selection = selection
|
|
|
+ },
|
|
|
+ search () {
|
|
|
+ this.fetch({
|
|
|
+ ...this.queryParams
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reset () {
|
|
|
+ this.queryParams = initQueryParams({})
|
|
|
+ this.$refs.table.clearSort()
|
|
|
+ this.$refs.table.clearFilter()
|
|
|
+ this.search()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 【删除】按钮-事件 groupSort
|
|
|
+ domDelete(row){
|
|
|
+ this.$confirm(this.$t("tips.comTips"), this.$t("common.tips"), {
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ // 过滤我们需要的数据
|
|
|
+ let list = this.tableData.filter(item => {
|
|
|
+ let f1 = item.id || item.key;
|
|
|
+ let f2 = row.id || row.key;
|
|
|
+ return f1 != f2
|
|
|
+ });
|
|
|
+ // 重新赋值
|
|
|
+ this.tableData = list;
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+
|
|
|
+ // 【删除】按钮-事件 groupSort
|
|
|
+ domDelete_v1(row){
|
|
|
+ this.$confirm(this.$t("tips.comTips"), this.$t("common.tips"), {
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ // 过滤需要的数据
|
|
|
+ let list = this.tableData.filter(item => item.groupSort != row.groupSort)
|
|
|
+ // 重新赋值
|
|
|
+ this.tableData = list
|
|
|
+
|
|
|
+ // 要合并列的准备数据
|
|
|
+ if(this.tableData.length > 0){
|
|
|
+ this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
+ this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 把值给父组件【程序】赋值
|
|
|
+ this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+
|
|
|
+ // 托盘【新增】按钮-事件
|
|
|
+ add () {
|
|
|
+ // 设置【组序】
|
|
|
+ if(this.tableData.length > 0){
|
|
|
+ let groupSort = parseInt(this.tableData[this.tableData.length -1].groupSort) + 1
|
|
|
+ this.$refs.add.tenant.groupSort = groupSort
|
|
|
+ }
|
|
|
+ this.$refs.add.setTenant(false)
|
|
|
+ this.dialogAdd.title = this.$t("common.add") + this.$t("prepare.common.tpJgroup")
|
|
|
+ this.dialogAdd.isVisible = true
|
|
|
+ },
|
|
|
+
|
|
|
+ // 托盘【修改】按钮-事件
|
|
|
+ addRow(row){
|
|
|
+ // 设置【组序】
|
|
|
+ this.$refs.add.tenant.groupSort = parseInt(row.groupSort)
|
|
|
+ this.$refs.add.setTenant(row)
|
|
|
+ this.dialogAdd.title = this.$t("common.edit") + this.$t("prepare.common.tpJgroup")
|
|
|
+ this.dialogAdd.isVisible = true
|
|
|
+ },
|
|
|
+
|
|
|
+ // 弹出框【取消】按钮-事件
|
|
|
+ editAddClose () {
|
|
|
+ this.dialogAdd.isVisible = false
|
|
|
+ },
|
|
|
+
|
|
|
+ // 弹出框【确定】按钮-事件
|
|
|
+ editAddSuccess (arr) {
|
|
|
+ // 通过深层复制,避免相同地址引起数据,一起改变
|
|
|
+ arr = JSON.parse(arr)
|
|
|
+ // 需要处理的最终数据
|
|
|
+ let list = []
|
|
|
+ // 把【新增-托盘】的对象信息拿出来,
|
|
|
+ let addObj = arr.filter(item => item.category.key == '03')[0]
|
|
|
+ // console.log("托盘夹具数据:", arr, addObj)
|
|
|
+ // 和已经有的数据,进行对比过滤
|
|
|
+ if(this.tableData.length > 0){
|
|
|
+ let isFlag = false; // 默认【托盘不存在】
|
|
|
+ // 已经存在的【托盘】的分组
|
|
|
+ let groupSort = ""
|
|
|
+ this.tableData.map(item => {
|
|
|
+ // 如果数据已经存在
|
|
|
+ if(item.trayId == addObj.trayId){
|
|
|
+ // console.log("wwwww :", item, addObj)
|
|
|
+ groupSort = item.groupSort
|
|
|
+ isFlag = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 如果存在,就比较。或者干脆全部删除
|
|
|
+ if(isFlag){
|
|
|
+ // console.log("【托盘】的分组groupSort: ", groupSort)
|
|
|
+ // 过滤已经存在的【托盘】分组数据
|
|
|
+ let target = this.tableData.filter(item => item.groupSort != groupSort)
|
|
|
+ // 合并数据
|
|
|
+ list = [...target, ...arr]
|
|
|
+ // console.log("【托盘】的分组2222: ", list)
|
|
|
+ }else{
|
|
|
+ // 合并当前数组,和新增的数组
|
|
|
+ list = [...this.tableData, ...arr]
|
|
|
+ }
|
|
|
+ // 进行排序
|
|
|
+ list = arrSort(list,"groupSort")
|
|
|
+ // 赋值
|
|
|
+ this.tableData = list
|
|
|
+ // console.log("最终数据:", list)
|
|
|
+ }else{
|
|
|
+ // 直接赋值
|
|
|
+ this.tableData = arr
|
|
|
+ }
|
|
|
+ // 要合并列的准备数据
|
|
|
+ if(this.tableData.length > 0){
|
|
|
+ this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
+ this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
+ }
|
|
|
+ // 把值给父组件【程序】赋值
|
|
|
+ this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
+ },
|
|
|
+
|
|
|
+ // 设置数据前,需要合并
|
|
|
+ setDataMustSpan(data){
|
|
|
+ this.tableData = data
|
|
|
+ // 要合并列的准备数据
|
|
|
+ if(data.length > 0){
|
|
|
+ this.spanArr = this.rowspanFiled(this.tableData, "groupSort")
|
|
|
+ this.spanArr2 = this.rowspanFiled(this.tableData, "groupPrority")
|
|
|
+ // 把值给父组件【程序】赋值
|
|
|
+ this.$emit("setProgram", this.tableData.filter(item => item.category.key == '03'))
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 【夹具】新增-事件
|
|
|
+ addTools(){
|
|
|
+ this.$refs.edit.type = "add";
|
|
|
+ this.dialog.title = this.$t("common.add") + this.$t("prepare.common.tab5");
|
|
|
+ this.dialog.isVisible = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 【夹具】修改-事件
|
|
|
+ editTools(row){
|
|
|
+ this.dialog.title = this.$t("common.edit") + this.$t("prepare.common.tab5");
|
|
|
+ this.$refs.edit.type = "edit";
|
|
|
+ // 赋值,修改的识别用。
|
|
|
+ let keys = row.id || row.key;
|
|
|
+ this.$refs.edit.keys = keys;
|
|
|
+ this.dialog.isVisible = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ editClose(){
|
|
|
+ this.dialog.isVisible = false
|
|
|
+ },
|
|
|
+
|
|
|
+ editSuccess(data, type){
|
|
|
+ // 最新数组
|
|
|
+ let list = []
|
|
|
+ // 深度Copy,防止翻车
|
|
|
+ let tool = JSON.parse(data);
|
|
|
+ let item = {
|
|
|
+ key: tool.key, // 关键字
|
|
|
+ trayPositionId: tool.id,
|
|
|
+ trayId: tool.trayId, // 夹具id
|
|
|
+ no: tool.no, // 编号
|
|
|
+ name: tool.name, // 名称
|
|
|
+ brand: tool.brand, // 品牌
|
|
|
+ category: tool.category // 物料类型
|
|
|
+ };
|
|
|
+ if (type == "add") {
|
|
|
+ // 添加,附件
|
|
|
+ item.jjImgList = [];
|
|
|
+ // 添加数据
|
|
|
+ list.push(item);
|
|
|
+ // 重新赋值
|
|
|
+ this.tableData = [...this.tableData, ...list];
|
|
|
+ } else {
|
|
|
+ let target = [];
|
|
|
+ this.tableData.map(obj => {
|
|
|
+ let f1 = obj.id;
|
|
|
+ let f2 = tool.key;
|
|
|
+ if(f1 == f2){
|
|
|
+ obj.trayPositionId = tool.id;
|
|
|
+ obj.trayId = tool.trayId; // 夹具id
|
|
|
+ obj.no = tool.no; // 编号
|
|
|
+ obj.name = tool.name; // 名称
|
|
|
+ obj.brand = tool.brand; // 品牌
|
|
|
+ obj.category = tool.category; // 物料类型
|
|
|
+ obj.jjImgList = []; // 附件
|
|
|
+ }
|
|
|
+ target.push(obj);
|
|
|
+ });
|
|
|
+ // 赋值
|
|
|
+ this.tableData = target;
|
|
|
+ console.log("最终数据:", this.tableData);
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ editSuccess_v1(obj){
|
|
|
+ // 深度Copy,防止翻车
|
|
|
+ let tool = JSON.parse(obj)
|
|
|
+ // console.log("选择的对象:", tool)
|
|
|
+ // console.log("当前选中的对象:", this.currentRow)
|
|
|
+ // 最新数组
|
|
|
+ let list = []
|
|
|
+ this.tableData.map(item => {
|
|
|
+ if(item.key == this.currentRow.key){
|
|
|
+ item.trayPositionId = tool.id
|
|
|
+ // 夹具id
|
|
|
+ item.trayId = tool.trayId,
|
|
|
+ item.no = tool.no // 编号
|
|
|
+ item.name = tool.name // 名称
|
|
|
+ item.brand = tool.brand // 品牌
|
|
|
+ }
|
|
|
+ // 添加数据
|
|
|
+ list.push(item)
|
|
|
+ })
|
|
|
+ // 重新赋值
|
|
|
+ this.tableData = list
|
|
|
+ },
|
|
|
+
|
|
|
+ clearSelections () {
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ },
|
|
|
+ delete (ids) {
|
|
|
+
|
|
|
+ },
|
|
|
+ view (row) {
|
|
|
+ this.$refs.view.setTenant(row)
|
|
|
+ this.tenantViewVisible = true
|
|
|
+ },
|
|
|
+ // 【修改】表头上Btn-事件
|
|
|
+ editOne() {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.selection.length > 1) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.mustOne"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.edit(this.selection[0]);
|
|
|
+ },
|
|
|
+ edit (row) {
|
|
|
+ if (row.readonly) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.systemData"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$refs.edit.setTenant(row)
|
|
|
+ this.$refs.edit.type = "edit"
|
|
|
+ this.dialog.title = this.$t("common.edit")
|
|
|
+ this.dialog.isVisible = true
|
|
|
+ },
|
|
|
+ fetch (params = {}) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+</style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .titleSmall{
|
|
|
+ position: relative;
|
|
|
+ padding-left: 10px;
|
|
|
+ margin-right: 15px;
|
|
|
+ }
|
|
|
+ .titleSmall:before{
|
|
|
+ content: '';
|
|
|
+ position: absolute;
|
|
|
+ background: #1890ff;
|
|
|
+ width: 5px;
|
|
|
+ height: 90%;
|
|
|
+ left: 0;
|
|
|
+ top: 1px;
|
|
|
+ }
|
|
|
+ .itemDiv{
|
|
|
+ margin: 10px 0;
|
|
|
+ }
|
|
|
+</style>
|