This commit is contained in:
2022-08-03 15:30:36 +08:00
parent 0e68a529c7
commit c124635c6d
3 changed files with 142 additions and 90 deletions

View File

@@ -183,6 +183,16 @@ function CRUD(options) {
callVmHook(crud, CRUD.HOOK.afterToAdd, crud.form) callVmHook(crud, CRUD.HOOK.afterToAdd, crud.form)
callVmHook(crud, CRUD.HOOK.afterToCU, crud.form) callVmHook(crud, CRUD.HOOK.afterToCU, crud.form)
}, },
/**
* 启动复制新增
* @param {*} data 数据项
*/
toCopy(data) {
crud.resetForm(JSON.parse(JSON.stringify(data)))
crud.status.add = CRUD.STATUS.PREPARED
callVmHook(crud, CRUD.HOOK.afterToAdd, crud.form)
callVmHook(crud, CRUD.HOOK.afterToCU, crud.form)
},
/** /**
* 启动编辑 * 启动编辑
* @param {*} data 数据项 * @param {*} data 数据项

View File

@@ -14,6 +14,7 @@
<!--左侧插槽--> <!--左侧插槽-->
<slot name="left"/> <slot name="left"/>
<el-button type="primary" @click="insertDtl">新增一行</el-button> <el-button type="primary" @click="insertDtl">新增一行</el-button>
<el-button type="primary" @click="copyAdd">复制新增</el-button>
</span> </span>
</div> </div>
<el-table <el-table
@@ -21,6 +22,8 @@
:data="tableData" :data="tableData"
style="width: 100%;" style="width: 100%;"
border border
highlight-current-row
@row-click="clickRow"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}" :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
> >
<el-table-column type="index" label="序号" width="50" align="center"/> <el-table-column type="index" label="序号" width="50" align="center"/>
@@ -89,21 +92,12 @@
<span v-show="scope.row.edit">{{ scope.row.plan_qty }}</span> <span v-show="scope.row.edit">{{ scope.row.plan_qty }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="planproducestart_date" label="计划开始时间" align="center" width="250px">
<template slot-scope="scope">
<el-date-picker
v-model="scope.row.planproducestart_date"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
style="width: 200px;"
/>
</template>
</el-table-column>
<el-table-column prop="shift_type_scode" label="班次类型" align="center" width="110px"> <el-table-column prop="shift_type_scode" label="班次类型" align="center" width="110px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select <el-select
v-model="scope.row.shift_type_scode" v-model="scope.row.shift_type_scode"
class="filter-item" class="filter-item"
@change="(val)=>change(val,scope.$index,scope.row)"
:disabled="scope.row.edit" :disabled="scope.row.edit"
> >
<el-option <el-option
@@ -115,7 +109,17 @@
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column show-overflow-tooltip prop="sale_id" label="销售单标识" align="center" width="150px"> <el-table-column prop="planproducestart_date" label="计划开始时间" align="center" width="250px">
<template slot-scope="scope">
<el-date-picker
v-model="scope.row.planproducestart_date"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
style="width: 200px;"
/>
</template>
</el-table-column>
<el-table-column prop="sale_id" label="销售单标识" align="center" width="150px">
<template scope="scope"> <template scope="scope">
<el-input v-model="scope.row.sale_id"/> <el-input v-model="scope.row.sale_id"/>
</template> </template>
@@ -178,6 +182,7 @@ export default {
return { return {
dialogVisible: false, dialogVisible: false,
materType: '01', materType: '01',
current_row: null,
workprocedureList: [], workprocedureList: [],
rows: [], rows: [],
materialShow: false, materialShow: false,
@@ -227,6 +232,14 @@ export default {
this.workprocedureList = res this.workprocedureList = res
}) })
}, },
copyAdd() {
if (!this.current_row) {
this.crud.notify('请选择一条工单进行复制!', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
const row = JSON.parse(JSON.stringify(this.current_row))
this.tableData.push(row)
},
close() { close() {
this.$emit('update:dialogShow', false) this.$emit('update:dialogShow', false)
this.$emit('AddChanged') this.$emit('AddChanged')
@@ -237,6 +250,20 @@ export default {
this.nowindex = index this.nowindex = index
this.nowrow = row this.nowrow = row
}, },
change(val, index, row) {
const d = new Date()
const year = d.getFullYear()
const month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1)
const day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
debugger
if (val === '02') {
row.planproducestart_date = [year, month, day].join('-') + ' ' + ['18', '30', '00'].join(':')
}
if (val === '01') {
row.planproducestart_date = [year, month, day].join('-') + ' ' + ['07', '30', '00'].join(':')
}
this.tableData.splice(index, 1, row)
},
setMaterValue(row) { setMaterValue(row) {
this.nowrow.material_id = row.material_id this.nowrow.material_id = row.material_id
this.nowrow.material_code = row.material_code this.nowrow.material_code = row.material_code
@@ -244,15 +271,16 @@ export default {
this.nowrow.material_spec = row.material_spec this.nowrow.material_spec = row.material_spec
this.tableData.splice(this.nowindex, 1, this.nowrow) // 通过splice 替换数据 触发视图更新 this.tableData.splice(this.nowindex, 1, this.nowrow) // 通过splice 替换数据 触发视图更新
}, },
clickRow(row) {
debugger
this.current_row = row
},
dateFormatter(str) { dateFormatter(str) {
const d = new Date(str) const d = new Date(str)
const year = d.getFullYear() const year = d.getFullYear()
const month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1) const month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1)
const day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate() const day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
const hour = d.getHours() < 10 ? '0' + d.getHours() : d.getHours() return [year, month, day].join('-') + ' ' + ['07', '30', '00'].join(':')
const minute = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
const second = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
return [year, month, day].join('-') + ' ' + [hour, minute, second].join(':')
}, },
deleteRow(index, rows) { deleteRow(index, rows) {
rows.splice(index, 1) rows.splice(index, 1)

View File

@@ -123,6 +123,17 @@
</div> </div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'--> <!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission"> <crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
:disabled="crud.selections.length !== 1"
@click="crud.toCopy(crud.selections[0])"
>
复制新增
</el-button>
<el-button <el-button
slot="right" slot="right"
class="filter-item" class="filter-item"
@@ -606,6 +617,9 @@ export default {
}, },
add() { add() {
this.addShow = true this.addShow = true
},
copyAdd(data) {
this.crud.toCopy(data)
} }
} }
} }