Files
wuHanXinRui/mes/qd/src/views/wms/pdm/produce/dailyplan/index.vue
2022-11-10 20:12:16 +08:00

454 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="90px"
label-suffix=":"
>
<el-form-item label="开始日期">
<el-date-picker
v-model="query.createTime"
type="daterange"
value-format="yyyy-MM-dd"
start-placeholder="开始日期"
end-placeholder="结束日期"
@input="onInput()"
@change="crud.toQuery"
/>
</el-form-item>
<el-form-item label="关键设备">
<label slot="label">关键设备:</label>
<el-select
v-model="query.device_id"
clearable
size="mini"
placeholder="关键设备"
class="filter-item"
style="width: 200px"
@change="hand"
>
<el-option
v-for="item in Devices"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="日计划编号">
<el-input
v-model="query.plan_code"
clearable
size="mini"
placeholder="请输入日计划编号"
style="width: 200px"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="状态">
<el-select
v-model="query.status"
clearable
size="mini"
placeholder="状态"
style="width: 200px"
class="filter-item"
@change="MyQuery"
>
<el-option
v-for="item in dict.planstatus"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="产品">
<el-input
v-model="query.material_code"
clearable
size="mini"
placeholder="请输入物料编码"
style="width: 200px"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="计划类型">
<el-select
v-model="query.workorder_type"
clearable
size="mini"
placeholder="计划类型"
style="width: 200px"
class="filter-item"
@change="MyQuery"
>
<el-option
v-for="item in dict.workorder_type2"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="初始日期">
<label slot="label">初始日期:</label>
<el-date-picker
v-model="query.nowstart_date"
type="date"
value-format="yyyy-MM-dd"
style="width: 200px"
placeholder="选择日期">
</el-date-picker>
<el-checkbox v-model="query.checked">启用</el-checkbox>
<rrOperation />
</el-form-item>
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation>
<el-button
slot="right"
class="filter-item"
type="primary"
icon="el-icon-position"
size="mini"
@click="save()"
>
重排
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
icon="el-icon-position"
size="mini"
@click="downdtl()"
>
导出excel
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
icon="el-icon-position"
size="mini"
@click="createWork()"
>
生成工令
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
icon="el-icon-top"
size="mini"
@click="moveUp2"
>
上移
</el-button>
<el-button
slot="right"
class="filter-item"
type="primary"
icon="el-icon-bottom"
size="mini"
@click="moveDown2"
>
下移
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" highlight-current-row :max-height="590" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler" @current-change="handleDtlCurrentChange">
<el-table-column
v-permission="['admin','workorder:del','workorder:edit']"
min-width="125"
label="操作"
align="center"
fixed="right"
>
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
:disabled-edit="canUd(scope.row)"
:disabled-dle="canUd(scope.row)"
/>
</template>
</el-table-column>
<el-table-column fixed="left" :selectable="checkboxT" type="selection" min-width="35" />
<el-table-column type="index" label="序号" min-width="40" align="center" />
<el-table-column prop="plan_code" label="日计划编码" min-width="105" />
<el-table-column :formatter="seriesFormat" min-width="75" prop="product_series_id" label="系列产线" />
<el-table-column prop="device_name" label="关键设备" min-width="80" />
<el-table-column prop="planstart_date" label="计划开始日期" min-width="100" />
<el-table-column prop="plan_org_name" label="申报单位" min-width="105" />
<el-table-column prop="workorder_type" label="计划类型" :formatter="workorder_typeFormat" min-width="75" />
<el-table-column prop="material_code" label="物料编码" min-width="130"/>
<el-table-column prop="old_mark" label="牌号" min-width="100" />
<el-table-column :formatter="seriesFormat2" min-width="75" prop="mater_product_series" label="产品系列" />
<el-table-column prop="product_weight" label="计划重量(kg)" :formatter="crud.formatNum0" min-width="100" />
<el-table-column prop="product_num" label="批数" min-width="50" />
<el-table-column prop="planend_date" label="计划结束日期" min-width="100" />
<el-table-column prop="plan_finish_date2" label="计划交货日期" min-width="100" />
<el-table-column :formatter="stateFormat" min-width="50" prop="status" label="状态" />
<el-table-column prop="task_code" label="生产任务号" min-width="110" />
<el-table-column prop="create_time" label="创建时间" min-width="135" />
<el-table-column prop="create_name" label="创建人" min-width="60" />
<el-table-column prop="remark" label="备注" min-width="200" />
</el-table>
</div>
<AddDialog @AddChanged="querytable" />
<StructIvt4 ref="child" :dialog-show.sync="structshow" :rowmst="form" @StructIvtClosed="querytable" />
</div>
</template>
<script>
import producetask from '@/api/wms/pdm/producetask'
import dailyplan from '@/api/wms/pdm/dailyplan'
import AddDialog from '@/views/wms/pdm/produce/dailyplan/AddDialog'
import StructIvt4 from '@/views/wms/pdm/produce/dailyplan/StructIvt4'
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { getToken } from '@/utils/auth'
import { mapGetters } from 'vuex'
import workorder from '@/api/wms/pdm/workorder'
import crudseriesProcessRoute from '@/api/wms/pdm/seriesProcessRoute'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
import Date from '@/utils/datetime'
export default {
name: 'dailyplan',
dicts: ['product_mode', 'workorder_type2', 'planstatus'],
components: { crudOperation, rrOperation, udOperation, AddDialog, pagination, StructIvt4 },
mixins: [presenter(), header(), crud()],
cruds() {
return CRUD({
title: '日计划管理',
url: 'api/dailyplan',
idField: 'dailyplan_id',
sort: '',
query: { nowstart_date: new Date(), device_id: '', status: '01' },
crudMethod: { ...dailyplan },
optShow: {
add: true,
edit: false,
del: true,
download: false,
reset: false
}})
},
data() {
return {
headers: { 'Authorization': getToken() },
permission: {
add: ['admin', 'workorder:add'],
edit: ['admin', 'workorder:edit'],
del: ['admin', 'workorder:del']
},
dialogVisible: false,
structshow: false,
save_flag: true,
sub_flag: true,
Depts: [],
Devices: [],
Capacitytes: [],
XLList: [],
fileList: [],
checkrows: [],
now_row: null,
form: {},
rules: {
}}
},
computed: {
...mapGetters([
'baseApi',
'fileUploadApi'
])
},
created() {
workorder.getDepts().then(res => {
this.Depts = res
})
producetask.getDevices().then(res => {
this.Devices = res
})
crudseriesProcessRoute.getXLlist2().then(res => {
this.XLList = res
})
producetask.getCapacitytes().then(res => {
this.Capacitytes = res
})
},
methods: {
[CRUD.HOOK.beforeRefresh]() {
this.now_row = null
return true
},
checkboxT(row) {
return row.status === '01'
},
canUd(row) {
return row.status !== '01'
},
hand(value) {
this.crud.toQuery()
},
stateFormat(row) {
return this.dict.label.planstatus[row.status]
},
workorder_typeFormat(row) {
return this.dict.label.workorder_type2[row.workorder_type]
},
onInput() {
this.$forceUpdate()
},
MyQuery(value) {
if (value === '1') {
this.save_flag = false
} else {
this.save_flag = true
}
this.crud.toQuery()
},
seriesFormat(row) {
for (const item of this.XLList) {
if (item.id === row.product_series) {
return item.name
}
}
},
seriesFormat2(row) {
for (const item of this.XLList) {
if (item.id === row.mater_product_series) {
return item.name
}
}
},
moveUp(index, item) {
if (index > 0) {
const upDate = this.crud.data[index - 1]
this.crud.data.splice(index - 1, 1)
this.crud.data.splice(index, 0, upDate)
} else {
this.$message.error('已经是第一条,不可上移')
}
},
moveDown(index, item) {
if ((index + 1) === this.crud.data.length) {
this.$message.error('已经是最后一条,不可下移')
} else {
console.log(index)
const downDate = this.crud.data[index + 1]
this.crud.data.splice(index + 1, 1)
this.crud.data.splice(index, 0, downDate)
}
},
save() {
if (this.crud.query.device_id === '' || this.crud.query.device_id === undefined) {
this.crud.notify('请先选择关键设备!')
return false
}
this.checkrows = this.crud.data
if (this.checkrows.length === 0) {
this.crud.notify('当前页面无可重排数据!')
return false
}
dailyplan.submit2({ query: this.crud.query, rows: this.checkrows }).then(res => {
this.form.device_id = this.crud.query.device_id
this.$refs.child.getMsg(this.crud.query.device_id, this.crud.query.nowstart_date, this.crud.query.checked)
this.structshow = true
})
},
downdtl() {
crud.downloadLoading = true
download('/api/dailyplan/download', this.crud.query).then(result => {
downloadFile(result, '日计划', 'xlsx')
crud.downloadLoading = false
}).catch(() => {
crud.downloadLoading = false
})
},
createWork() {
this.checkrows = this.$refs.table.selection
if (this.checkrows.length === 0) {
this.crud.notify('请勾选需要操作的记录!')
return false
}
this.crud.loading = true
dailyplan.submit({ query: this.crud.query, rows: this.checkrows }).then(res => {
this.crud.notify('操作成功!')
this.querytable()
}).catch(() => {
this.crud.loading = false
})
},
handleDtlCurrentChange(current) {
if (current !== null) {
this.now_row = current
} else {
this.now_row = null
}
},
moveUp2() {
if (this.now_row === null) {
return this.crud.notify('请选中一条数据!')
}
const data = this.crud.data
for (let i = 0; i < data.length; i++) {
if (data[i].plan_code === this.now_row.plan_code) {
if (i > 0) {
const upDate = this.crud.data[i - 1]
this.crud.data.splice(i - 1, 1)
this.crud.data.splice(i, 0, upDate)
} else {
this.$message.error('已经是第一条,不可上移')
}
}
}
},
moveDown2() {
if (this.now_row === null) {
return this.crud.notify('请选中一条数据!')
}
const data = this.crud.data
for (let i = 0; i < data.length; i++) {
if (data[i].plan_code === this.now_row.plan_code) {
if ((i + 1) === this.crud.data.length) {
this.$message.error('已经是最后一条,不可下移')
} else {
const downDate = this.crud.data[i + 1]
this.crud.data.splice(i + 1, 1)
this.crud.data.splice(i, 0, downDate)
break
}
}
}
},
querytable() {
this.crud.toQuery()
}
}
}
</script>
<style scoped>
</style>