<template>
|
<div>
|
<div class="body" :style="{height:mainHeight+'px'}">
|
<div style="padding: 10px 5px 0 0">
|
<el-form
|
ref="form"
|
:model="form"
|
label-width="80px"
|
inline
|
style="display: flex;justify-content: space-between"
|
>
|
<div class="elForm">
|
<el-form-item label="工序编码" style=" display: flex;">
|
<el-input v-model="form.stepcode" placeholder="请输入" style="width: 200px" />
|
</el-form-item>
|
<el-form-item label="工序名称" style=" display: flex;">
|
<el-input v-model="form.stepname" placeholder="请输入" style="width: 200px" />
|
</el-form-item>
|
<el-form-item label="启用状态" style=" display: flex;">
|
<el-select v-model="form.enable" :popper-append-to-body="false" style="width: 200px" placeholder="请选择">
|
<el-option
|
v-for="item in enableArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工序类型" style=" display: flex;">
|
<el-select
|
v-model="form.steptypecode"
|
:popper-append-to-body="false"
|
style="width: 200px"
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="item in steptypeArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="创建人员" style=" display: flex;">
|
<el-input v-model="form.createuser" style="width: 200px" placeholder="请输入" />
|
</el-form-item>
|
</div>
|
<div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
|
<el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
|
<el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
|
</div>
|
</el-form>
|
</div>
|
<el-divider />
|
<div style="margin-left: 10px;display: flex">
|
<el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
|
<el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
|
</div>
|
<el-divider />
|
<div class="elTableDiv">
|
<el-table
|
:data="tableData"
|
:height="tableHeight"
|
border
|
stripe
|
:style="{width: 100+'%',height:tableHeight+'px',}"
|
highlight-current-row
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
@sort-change="sortChange"
|
>
|
<!-- <el-table-column-->
|
<!-- type="selection"-->
|
<!-- width="50"-->
|
<!-- />-->
|
<el-table-column
|
prop="RowNum"
|
width="50"
|
label="序号"
|
/>
|
<el-table-column
|
prop="stepcode"
|
label="工序编码"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="stepname"
|
label="工序名称"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="flwtype"
|
label="工序类型"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.flwtype.indexOf(';')!==-1">自制;外协</div>
|
<div v-if="row.flwtype==='W'">外协</div>
|
<div v-if="row.flwtype==='Z'">自制</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="descr"
|
label="工序描述"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="enable"
|
label="启用状态"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.enable==='Y'">是</div>
|
<div v-if="row.enable==='N'">否</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="lm_user"
|
label="创建人员"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="lm_date"
|
label="创建时间"
|
sortable="custom"
|
/>
|
<el-table-column
|
label="关联工作站"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<i class="el-icon-share" @click="workClick(row)" />
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="关联缺陷"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<i class="el-icon-share" @click="defectClick(row)" />
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-button type="text" @click="edit('edit',row)">编辑</el-button>
|
<el-button type="text" @click="del(row)">删除</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<!--分页-->
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="form.page"
|
:limit.sync="form.rows"
|
align="right"
|
layout="prev, pager, next,sizes"
|
popper-class="select_bottom"
|
@pagination="getStepSearch"
|
/>
|
</div>
|
|
<!--新增修改对话框-->
|
<el-dialog
|
:title="operation==='add'?'新增':'编辑'"
|
:visible.sync="dialogVisible"
|
width="50%"
|
:close-on-click-modal="false"
|
top="15vh"
|
@closed="handleClose"
|
@close="handleClose"
|
>
|
<el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
|
<el-form-item label="工序编码" prop="stepcode">
|
<el-input v-model="dialogForm.stepcode" :disabled="operation!=='add'" style="width: 220px" />
|
</el-form-item>
|
<el-form-item label="工序名称" prop="stepname">
|
<el-input v-model="dialogForm.stepname" style="width: 220px" />
|
</el-form-item>
|
<el-form-item prop="steptypecode" label="工序类型">
|
<el-select
|
v-model="dialogForm.steptypecode"
|
style="width: 220px"
|
placeholder="请选择"
|
:popper-append-to-body="false"
|
>
|
<el-option
|
v-for="item in steptypeArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item prop="enable" label="启用状态">
|
<el-select
|
v-model="dialogForm.enable"
|
style="width: 220px"
|
placeholder="请选择"
|
:popper-append-to-body="false"
|
>
|
<el-option
|
v-for="item in enableArr"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="工序描述" prop="description">
|
<el-input v-model="dialogForm.description" type="textarea" style="width: 220px" />
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="dialogVisibleCancel">取 消</el-button>
|
<el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
|
<!-- 关联工作站对话框-->
|
<el-dialog
|
title="关联工作站"
|
:visible.sync="workDialogVisible"
|
width="50%"
|
top="15vh"
|
:close-on-click-modal="false"
|
class="workDialogVisible"
|
@closed="workHandleClose"
|
@close="workHandleClose"
|
>
|
<!-- @opened="handleOpenedRoles"-->
|
|
<div>
|
<i class="el-icon-s-comment" style="color:#42b983;" /> 工序名称:{{ workDialogForm.stepname }}
|
</div>
|
<el-divider />
|
<div>
|
<div style="margin-bottom:20px">
|
<i class="el-icon-s-operation" style="color:#42b983;" /> 工作站集合:
|
</div>
|
<div class="myCheckboxGroup">
|
<div
|
v-for="item in workDialogForm.workGatherArr"
|
:key="item.code"
|
:style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
|
class="myCheckbox"
|
@click="myCheckboxClick(item)"
|
>
|
<input
|
class="myCheckboxInput"
|
type="checkbox"
|
:value="item.code"
|
name="gather"
|
:style="{color:item.isSelected2?'#42b983':'#fff'}"
|
@click="myCheckboxInputClick(item)"
|
>{{ item.name }}
|
<!-- 父子点击事件不影响-->
|
<!-- onClick="event.cancelBubble = true"-->
|
</div>
|
</div>
|
</div>
|
<el-divider />
|
<div>
|
<div style="margin-bottom:20px">
|
<i class="el-icon-s-operation" style="color:#42b983;" /> 工作站:
|
</div>
|
<el-tree
|
ref="workTree"
|
:data="workDialogForm.workTreeArr"
|
show-checkbox
|
node-key="code"
|
default-expand-all
|
:props="workTreeDefaultProps"
|
@check="checkBoxClick"
|
/>
|
<!-- @check-change="checkChange"-->
|
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="workDialogVisibleCancel">取 消</el-button>
|
<el-button type="primary" @click="workDialogVisibleConfirm">确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
|
<!-- 关联缺陷对话框-->
|
<el-dialog
|
title="工序关联缺陷"
|
:visible.sync="defectDialogVisible"
|
width="50%"
|
top="15vh"
|
:close-on-click-modal="false"
|
class="defectDialogVisible"
|
@closed="defectHandleClose"
|
@close="defectHandleClose"
|
>
|
<!-- @opened="handleOpenedRoles"-->
|
|
<div style="margin-bottom: 20px">
|
<i class="el-icon-s-comment" style="color:#42b983;" /> 工序名称:{{ defectTreeName }}
|
</div>
|
|
<div>
|
<!-- <div style="margin-bottom:20px">-->
|
<!-- <i class="el-icon-s-operation" style="color:#42b983;" /> 工作站:-->
|
<!-- </div>-->
|
<el-tree
|
ref="defectTree"
|
:data="defectTree"
|
show-checkbox
|
node-key="code"
|
style="height: 400px;"
|
default-expand-all
|
:props="workTreeDefaultProps"
|
/>
|
<!-- @check="checkBoxClick"-->
|
<!-- @check-change="checkChange"-->
|
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="defectDialogVisibleCancel">取 消</el-button>
|
<el-button type="primary" @click="defectDialogVisibleConfirm">确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
|
</div>
|
</template>
|
|
<script>
|
import Pagination from '@/components/Pagination'
|
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
|
import { getCookie } from '@/utils/auth'
|
import {
|
AddUpdateStep,
|
DeleteStep, SaveStepAssociationDefect,
|
SaveStepAssociationEqp,
|
StepAssociationDefect,
|
StepAssociationEqp,
|
StepSearch
|
} from '@/api/zzmx'
|
import $ from 'jquery'
|
|
const SER_HZ = /^[\u4e00-\u9fa5]+$/
|
export default {
|
name: 'Zzjg',
|
components: {
|
Pagination
|
},
|
data() {
|
const validateName = (rule, value, callback) => {
|
if (!value) {
|
return callback(new Error('请输入编码'))
|
} else {
|
if (SER_HZ.test(value)) {
|
return callback(new Error('编码不能为中文'))
|
} else {
|
callback()
|
}
|
}
|
}
|
return {
|
mainHeight: 0,
|
tableHeight: 0,
|
form: {
|
stepcode: '', // 工序编码
|
stepname: '', // 工序名称
|
enable: '', // 启用状态
|
steptypecode: [], // 工序类型编码
|
createuser: '', // 创建人员
|
prop: 'lm_date', // 排序字段
|
order: 'desc', // 排序字段
|
page: 1, // 第几页
|
rows: 20 // 每页多少条
|
},
|
enableArr: [
|
{ code: 'Y', name: '是' },
|
{ code: 'N', name: '否' }
|
],
|
steptypeArr: [
|
{ code: 'Z', name: '自制' },
|
{ code: 'W', name: '外协' }
|
// { code: 'Z;W', name: '自制;外协' }
|
],
|
total: 10,
|
tableData: [],
|
dialogVisible: false,
|
dialogForm: {
|
'id': '',
|
'stepcode': '',
|
'stepname': '',
|
'steptypecode': '',
|
'enable': '',
|
'description': '',
|
'OperType': ''
|
},
|
operation: '',
|
dialogFormRules: {
|
stepcode: [
|
{ required: true, validator: validateName, trigger: ['blur', 'change'] }
|
],
|
stepname: [
|
{ required: true, message: '请输入名称', trigger: ['blur', 'change'] }
|
],
|
steptypecode: [
|
{ required: true, message: '请选择类型', trigger: ['blur', 'change'] }
|
],
|
enable: [
|
{ required: true, message: '请选择状态', trigger: ['blur', 'change'] }
|
]
|
},
|
workDialogVisible: false,
|
workDialogForm: {
|
stepcode: '', // 工序编码
|
stepname: '', // 工序名称
|
workArr: [], // 工作站所有数组
|
workGatherArr: [], // 工作站集合数组
|
workCodeSelectedGatherArr: [], // 工作站选中集合的code数组
|
workTreeArr: [], // 工作站树数组
|
workTreeSelectedArr: []// 工作站树选中的数组code集合
|
},
|
workTreeDefaultProps: {
|
value: 'code',
|
label: 'name',
|
children: 'children'
|
},
|
defectDialogVisible: false,
|
defectTreeCode: '',
|
defectTreeName: '',
|
defectTree: []
|
|
}
|
},
|
created() {
|
this.getStepSearch()
|
},
|
mounted() {
|
window.addEventListener('resize', this.getHeight)
|
this.getHeight()
|
},
|
methods: {
|
async getStepSearch() {
|
const res = await StepSearch(this.form)
|
this.tableData = res.data
|
this.total = res.count
|
},
|
// 排序改变时
|
sortChange({ column, prop, order }) {
|
if (order === 'descending') {
|
order = 'desc'
|
} else if (order === 'ascending') {
|
order = 'asc'
|
} else {
|
order = 'desc'
|
}
|
this.form.order = order
|
this.form.prop = prop
|
this.getStepSearch()
|
},
|
// 查询
|
search() {
|
this.getStepSearch()
|
},
|
upload() {
|
|
},
|
// 重置
|
reset() {
|
this.form.stepcode = ''
|
this.form.stepname = ''
|
this.form.enable = ''
|
this.form.steptypecode = ''
|
this.form.createuser = ''
|
this.getStepSearch()
|
},
|
|
// 新增按钮
|
add(operation) {
|
this.operation = operation
|
this.dialogVisible = true
|
},
|
// 修改按钮
|
edit(operation, row) {
|
this.operation = operation
|
this.dialogVisible = true
|
|
this.$nextTick(() => {
|
this.dialogForm.id = row.id
|
this.dialogForm.stepcode = row.stepcode
|
this.dialogForm.stepname = row.stepname
|
this.dialogForm.steptypecode = row.flwtype
|
this.dialogForm.description = row.descr
|
this.dialogForm.enable = row.enable
|
})
|
},
|
// 删除按钮
|
async del(row) {
|
this.$confirm('是否确认删除?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
DeleteStep({ stepcode: row.stepcode }).then(res => {
|
if (res.code === '200') {
|
this.$message.success('删除成功!')
|
this.getStepSearch()
|
}
|
})
|
}).catch(() => {
|
this.$message.info('已取消删除')
|
})
|
},
|
// 对话框关闭事件
|
handleClose() {
|
this.dialogForm.stepcode = ''
|
this.dialogForm.stepname = ''
|
this.dialogForm.steptypecode = ''
|
this.dialogForm.enable = ''
|
this.dialogForm.description = ''
|
this.$refs.dialogForm.clearValidate()
|
},
|
// 对话框取消
|
dialogVisibleCancel() {
|
this.dialogVisible = false
|
},
|
// 对话框确认
|
dialogVisibleConfirm() {
|
this.$refs.dialogForm.validate(valid => {
|
if (valid) {
|
const data = {
|
id: this.dialogForm.id,
|
stepcode: this.dialogForm.stepcode,
|
stepname: this.dialogForm.stepname,
|
steptypecode: this.dialogForm.steptypecode,
|
enable: this.dialogForm.enable,
|
description: this.dialogForm.description,
|
OperType: this.operation === 'add' ? 'Add' : 'Update'
|
}
|
AddUpdateStep(data).then(res => {
|
if (res.code === '200') {
|
this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
|
this.dialogVisible = false
|
this.getStepSearch()
|
} else {
|
this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
|
}
|
})
|
}
|
})
|
},
|
// 获取页面高度
|
getHeight() {
|
this.$nextTick(() => {
|
this.mainHeight = window.innerHeight - 250
|
this.tableHeight = this.mainHeight - 100
|
})
|
},
|
/* 关联工作站模块*/
|
// 关联工作站点击
|
async workClick(row) {
|
this.workDialogVisible = true
|
this.workDialogForm.stepcode = row.stepcode
|
this.workDialogForm.stepname = row.stepname
|
const { data: res } = await StepAssociationEqp({ stepcode: this.workDialogForm.stepcode })
|
this.workDialogForm.workArr = res
|
let workGatherArr = []
|
if (row.flwtype === 'W') { // 外协情况下
|
workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'W')
|
} else if (row.flwtype === 'Z') { // 自制情况下
|
workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'E')
|
} else { // 自制+外协
|
workGatherArr = this.workDialogForm.workArr
|
}
|
// this.workDialogForm.workArr[1].children = []
|
const nodeKey = []// 需要树形数显的值
|
workGatherArr.forEach((item, index) => {
|
this.workDialogForm.workGatherArr.push({
|
isSelected1: index === 0,
|
isSelected2: item.flag === 'Y',
|
code: item.code,
|
name: item.name,
|
type: item.type,
|
flag: item.flag
|
})
|
if (item.flag === 'Y' && item.children && item.children.length > 0) {
|
this.$nextTick(() => {
|
$("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
|
})
|
item.children.forEach(it => {
|
if (it.flag === 'Y') {
|
nodeKey.push(it.code)
|
}
|
})
|
}
|
if (index === 0) {
|
if (item.children && item.children.length > 0) {
|
this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(it => it.code === item.code)
|
this.workDialogForm.workTreeArr[0].name = '全部'
|
}
|
}
|
// item.flag === 'Y'&&item
|
})
|
console.log(nodeKey, 1)
|
this.$refs.workTree.setCheckedKeys(nodeKey)
|
this.workDialogForm.workTreeSelectedArr = nodeKey
|
|
console.log(this.workDialogForm.workGatherArr, 6)
|
console.log(this.workDialogForm.workTreeArr, 7)
|
},
|
// 大盒子点击事件
|
myCheckboxClick(val) {
|
console.log(val.code, 3)
|
// 点击不同的盒子进行选中样式切换
|
this.workDialogForm.workGatherArr.find(item => {
|
item.isSelected1 = item.code === val.code
|
})
|
this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(item => item.code === val.code)
|
if (this.workDialogForm.workTreeArr[0].children && this.workDialogForm.workTreeArr[0].children.length > 0) {
|
this.workDialogForm.workTreeArr[0].name = '全部'
|
} else {
|
this.workDialogForm.workTreeArr = []
|
}
|
|
console.log(this.workDialogForm.workTreeArr, 8)
|
},
|
// 小盒子点击事件
|
myCheckboxInputClick(val) {
|
val.isSelected2 = !val.isSelected2
|
console.log(val.code, 1)
|
this.workDialogForm.workCodeSelectedGatherArr = [...new Set(this.workDialogForm.workCodeSelectedGatherArr)]
|
// 1.第一种情况 小盒子从没选中到选中
|
if (val.isSelected2) {
|
console.log('1.第一种情况 小盒子从没选中到选中')
|
this.workDialogForm.workCodeSelectedGatherArr.push(val.code)
|
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === val.code) {
|
item.flag = 'Y'
|
if (item.children && item.children.length > 0) {
|
item.children.forEach(it => {
|
it.flag = 'Y'
|
this.workDialogForm.workTreeSelectedArr.push(it.code)
|
})
|
}
|
}
|
})
|
}
|
|
// 2.第二种情况 小盒子从选中到没选中
|
if (!val.isSelected2) {
|
console.log('2.第二种情况 小盒子从选中到没选中')
|
this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(item => item !== val.code)
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === val.code) {
|
item.flag = 'N'
|
if (item.children && item.children.length > 0) {
|
item.children.forEach(it => {
|
it.flag = 'N'
|
this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
|
if (i === it.code) {
|
this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
|
}
|
})
|
})
|
}
|
}
|
})
|
}
|
this.workDialogForm.workCodeSelectedGatherArr = [...new Set(this.workDialogForm.workCodeSelectedGatherArr)]
|
|
console.log(this.workDialogForm.workCodeSelectedGatherArr, 2)
|
console.log(this.workDialogForm.workTreeSelectedArr, 23)
|
// this.$refs.workTree.setCheckedKeys(this.workDialogForm.workCodeSelectedGatherArr)
|
this.$refs.workTree.setCheckedKeys(this.workDialogForm.workTreeSelectedArr)
|
},
|
// 树形中 框选中
|
checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
|
console.log(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys })
|
|
let checkedFatherCode = '' // 找到 checkedFatherCode 父code值
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === obj.code) {
|
checkedFatherCode = item.code
|
}
|
if (item.children && item.children.length > 0) {
|
item.children.forEach((it, ind) => {
|
if (it.code === obj.code) {
|
checkedFatherCode = item.code
|
}
|
})
|
}
|
})
|
|
// 1.第一种情况 半叶为零 全叶为零
|
if (checkedKeys.length === 0 && halfCheckedKeys.length === 0) {
|
console.log('1.第一种情况 半叶为零 全叶为零')
|
console.log(obj.code, 10)
|
// this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(item => item !== obj.code)
|
|
this.workDialogForm.workGatherArr.forEach((item, index) => {
|
if (item.code === checkedFatherCode) {
|
this.workDialogForm.workGatherArr[index].isSelected2 = false
|
|
// item.isSelected1 = item.code === checkedFatherCode
|
this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(it => it !== checkedFatherCode)
|
this.$nextTick(() => {
|
// console.log($("input[name='gather']"))
|
$("input[name='gather']").eq(index).prop('checked', false)// 自定义单选框回显
|
})
|
}
|
})
|
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === checkedFatherCode) {
|
item.flag = 'N'
|
if (item.children && item.children.length > 0) {
|
item.children.forEach((it) => {
|
it.flag = 'N'
|
this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
|
if (i === it.code) {
|
this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
|
}
|
})
|
})
|
}
|
}
|
})
|
console.log(this.workDialogForm.workCodeSelectedGatherArr, 11)
|
console.log(this.workDialogForm.workTreeSelectedArr, 18)
|
}
|
|
// 2.第二种情况 半叶不为零 全叶不为零
|
if (checkedKeys.length !== 0 && halfCheckedKeys.length !== 0) {
|
console.log('2.第二种情况 半叶不为零 全叶不为零')
|
console.log(obj.code, 13)
|
// console.log(this.$refs.workTree, 22)
|
|
this.workDialogForm.workGatherArr.forEach((item, index) => {
|
if (item.code === checkedFatherCode) {
|
this.workDialogForm.workGatherArr[index].isSelected2 = true
|
// this.workDialogForm.workCodeSelectedGatherArr.push(obj.code)
|
this.$nextTick(() => {
|
$("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
|
})
|
}
|
})
|
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === checkedFatherCode) {
|
item.flag = 'Y'
|
if (item.children && item.children.length > 0) {
|
item.children.forEach(it => {
|
if (it.code === obj.code) {
|
console.log(it.code, 21)
|
if (it.flag === 'Y' && it.code === obj.code) {
|
it.flag = 'N'
|
this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
|
if (i === it.code) {
|
console.log(i, 333)
|
this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
|
}
|
})
|
} else if (it.flag === 'N' && it.code === obj.code) {
|
it.flag = 'Y'
|
console.log(2222)
|
this.workDialogForm.workTreeSelectedArr.push(it.code)
|
}
|
}
|
})
|
}
|
|
console.log(this.workDialogForm.workTreeSelectedArr, 17)
|
|
// this.$nextTick(() => {
|
// $("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
|
// })
|
}
|
})
|
}
|
|
// 3.第三种情况 半叶为零 全叶不为零
|
if (checkedKeys.length !== 0 && halfCheckedKeys.length === 0) {
|
console.log('3.第三种情况 半叶为零 全叶不为零')
|
console.log(obj.code, 12)
|
this.workDialogForm.workGatherArr.forEach((item, index) => {
|
if (item.code === obj.code) {
|
this.workDialogForm.workGatherArr[index].isSelected2 = true
|
this.workDialogForm.workCodeSelectedGatherArr.push(obj.code)
|
this.$nextTick(() => {
|
$("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
|
})
|
}
|
})
|
|
this.workDialogForm.workArr.forEach((item, index) => {
|
if (item.code === checkedFatherCode) {
|
item.flag = 'Y'
|
if (item.children && item.children.length > 0) {
|
item.children.forEach(it => {
|
it.flag = 'Y'
|
this.workDialogForm.workTreeSelectedArr.push(it.code)
|
})
|
}
|
}
|
})
|
}
|
this.workDialogForm.workTreeSelectedArr = [...new Set(this.workDialogForm.workTreeSelectedArr)]
|
|
this.$refs.workTree.setCheckedKeys(this.workDialogForm.workTreeSelectedArr)
|
console.log(this.workDialogForm.workTreeSelectedArr, 14)
|
console.log(this.workDialogForm.workArr, 15)
|
},
|
// 对话框关闭事件
|
workHandleClose() {
|
this.workDialogForm.workArr = []
|
this.workDialogForm.workGatherArr = []
|
this.workDialogForm.workTreeArr = []
|
this.$refs.workTree.setCheckedKeys([])
|
},
|
// 取消
|
workDialogVisibleCancel() {
|
this.workDialogVisible = false
|
},
|
// 确认
|
async workDialogVisibleConfirm() {
|
this.workDialogForm.workTreeSelectedArr = [...new Set(this.workDialogForm.workTreeSelectedArr)]
|
console.log(this.workDialogForm.workTreeSelectedArr, 18)
|
console.log(this.workDialogForm.workArr, 20)
|
const data = []
|
this.workDialogForm.workArr.forEach(item => {
|
if (item.flag === 'Y' && item.children && item.children.length > 0) {
|
item.children.forEach(it => { // 保存接口只传最子项 name传的是type
|
if (it.flag === 'Y') {
|
data.push({ code: it.code, name: it.type })
|
}
|
})
|
}
|
})
|
console.log(data)
|
const res = await SaveStepAssociationEqp(this.workDialogForm.stepcode, data)
|
if (res.code === '200') {
|
this.$message.success('保存成功!')
|
this.workDialogVisible = false
|
}
|
},
|
/* 关联缺陷*/
|
// 关联缺陷点击
|
async defectClick(row) {
|
this.defectTreeCode = row.stepcode
|
this.defectTreeName = row.stepname
|
this.defectDialogVisible = true
|
|
const { data: res } = await StepAssociationDefect({ stepcode: row.stepcode })
|
// this.defectTree = res
|
this.defectTree.push({ code: 'QB', name: '全部', children: res, flag: 'N' })
|
console.log(this.defectTree, 6)
|
const nokeKey = []
|
this.defectTree[0].children.forEach(item => {
|
if (item.flag === 'Y') {
|
nokeKey.push(item.code)
|
}
|
})
|
console.log(nokeKey, 2)
|
this.$nextTick(() => {
|
this.$refs.defectTree.setCheckedKeys(nokeKey)
|
})
|
},
|
// 关闭
|
defectHandleClose() {
|
this.defectTree = []
|
},
|
// 取消
|
defectDialogVisibleCancel() {
|
this.defectDialogVisible = false
|
},
|
// 确认
|
async defectDialogVisibleConfirm() {
|
const nodeKey = this.$refs.defectTree.getCheckedKeys()
|
const data = []
|
this.defectTree[0].children.forEach(item => {
|
if (nodeKey.includes(item.code)) {
|
console.log(item.code)
|
data.push({ code: item.code, name: item.name })
|
}
|
})
|
const res = await SaveStepAssociationDefect(this.defectTreeCode, data)
|
if (res.code === '200') {
|
this.$message.success('保存成功!')
|
this.defectDialogVisible = false
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
$main_color: #42b983;
|
::v-deep .el-button--primary {
|
background-color: $main_color !important;
|
height: 30px;
|
display: flex;
|
align-items: center;
|
//border: 1px solid $main_color;
|
border: none;
|
padding: 0 20px;
|
}
|
|
::v-deep .el-button--primary:hover {
|
border: none;
|
}
|
|
::v-deep .el-button--info {
|
height: 30px;
|
display: flex;
|
align-items: center;
|
padding: 0 20px;
|
}
|
|
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
|
background-color: $main_color !important;
|
}
|
|
::v-deep .el-dialog__footer {
|
display: flex;
|
justify-content: flex-end;
|
}
|
|
.footerButton {
|
display: flex;
|
justify-content: end;
|
}
|
|
::v-deep .el-button--default {
|
background-color: #ffffff !important;
|
height: 30px;
|
display: flex;
|
align-items: center;
|
padding: 0 20px;
|
}
|
|
::v-deep .el-button--default:hover {
|
color: #606266;
|
}
|
|
::v-deep .el-dialog__body {
|
padding: 20px 100px !important;
|
}
|
|
.defectDialogVisible {
|
::v-deep .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
}
|
|
.workDialogVisible {
|
::v-deep .el-dialog__body {
|
padding: 20px 20px !important;
|
}
|
|
.myCheckboxGroup {
|
display: flex;
|
flex-wrap: wrap;
|
|
.myCheckbox {
|
border: 1px solid #eee;
|
display: flex;
|
min-width: 100px;
|
padding: 10px;
|
margin: 10px 30px 0 0;
|
border-radius: 5px;
|
cursor: default;
|
|
.myCheckboxInput {
|
margin: 1px 5px 0 0;
|
cursor: pointer;
|
}
|
|
}
|
|
input[type=checkbox] {
|
cursor: pointer;
|
position: relative;
|
width: 14px;
|
height: 14px;
|
font-size: 14px;
|
}
|
|
input[type=checkbox]::after {
|
position: absolute;
|
top: 0;
|
color: $main_color;
|
width: 14px;
|
height: 14px;
|
display: inline-block;
|
visibility: visible;
|
padding-left: 0;
|
text-align: center;
|
content: ' ';
|
border-radius: 3px
|
}
|
|
input[type=checkbox]:checked::after {
|
content: "✓";
|
//content: "√";
|
color: #fff;
|
font-size: 12px;
|
font-weight: bold;
|
background-color: $main_color;
|
}
|
}
|
}
|
|
::v-deep .el-radio__input.is-checked .el-radio__inner {
|
background-color: $main_color;
|
border-color: $main_color;
|
}
|
|
::v-deep .el-radio__input.is-checked + .el-radio__label {
|
color: $main_color !important;
|
}
|
|
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
|
border-color: $main_color;
|
background-color: $main_color;
|
}
|
|
::v-deep .el-input__inner {
|
height: 30px;
|
line-height: 30px;
|
}
|
|
::v-deep .el-input__inner:focus {
|
border-color: $main_color;
|
}
|
|
::v-deep .el-table .caret-wrapper {
|
transform: scale(0.8);
|
}
|
|
::v-deep .cell {
|
display: flex !important;
|
align-items: center !important;
|
justify-content: space-between !important;
|
}
|
|
::v-deep .el-button--text {
|
color: $main_color;
|
font-size: 14px;
|
cursor: pointer;
|
}
|
|
.operationClass {
|
height: 23px;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.el-icon-share {
|
color: $main_color;
|
cursor: pointer;
|
}
|
|
.el-checkbox.is-bordered.is-checked {
|
border-color: $main_color;
|
}
|
|
::v-deep .el-radio__input.is-checked .el-radio__inner {
|
border-color: $main_color;
|
background: $main_color;
|
}
|
|
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
|
border-color: $main_color;
|
background: $main_color;
|
}
|
|
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
|
color: $main_color !important;
|
}
|
|
::v-deep .el-checkbox.is-bordered + .el-checkbox.is-bordered {
|
margin: 10px 30px 0px 0;
|
}
|
|
::v-deep .el-radio__input.is-checked + .el-radio__label {
|
color: $main_color;
|
}
|
|
::v-deep .el-radio.is-bordered + .el-radio.is-bordered {
|
margin: 10px 30px 0px 0;
|
}
|
|
.body ::v-deep .el-divider {
|
border: 1px solid #eee;
|
width: 99%;
|
margin: 10px auto;
|
}
|
|
.body ::v-deep .el-form-item {
|
margin-bottom: 0;
|
}
|
|
::v-deep .el-input__inner:focus {
|
border-color: $main_color;
|
}
|
|
::v-deep .el-select .el-input__inner:focus {
|
border-color: $main_color;
|
}
|
|
::v-deep .el-select-dropdown__item.selected {
|
color: $main_color;
|
}
|
|
::v-deep .el-checkbox__inner:hover {
|
border-color: $main_color;
|
}
|
|
::v-deep .el-textarea__inner:focus {
|
border-color: $main_color;
|
}
|
|
</style>
|