update 压机报工页面

This commit is contained in:
lb 2023-08-18 11:02:01 +08:00
parent 3adabb68b8
commit 58f86a9b2b
4 changed files with 178 additions and 18 deletions

View File

@ -16,6 +16,14 @@
<!-- :class="{ 'pms-dialog--rotate-down': startLeave }"> --> <!-- :class="{ 'pms-dialog--rotate-down': startLeave }"> -->
<span slot="title" class="dialog-title">报工预览</span> <span slot="title" class="dialog-title">报工预览</span>
<!-- 面包屑导航 -->
<div style="padding: 12px; background: #f7f7f7">
<el-breadcrumb separator="/">
<el-breadcrumb-item>预报工单</el-breadcrumb-item>
<el-breadcrumb-item v-if="mode.includes('form')">编辑</el-breadcrumb-item>
</el-breadcrumb>
</div>
<transition class="l" mode="out-in"> <transition class="l" mode="out-in">
<BaseListTable <BaseListTable
v-if="mode.includes('table')" v-if="mode.includes('table')"
@ -25,15 +33,67 @@
@operate-event="handleOperate" @operate-event="handleOperate"
:current-page="page" :current-page="page"
:current-size="size" /> :current-size="size" />
<form action="#" v-if="mode.includes('form')">
<h1>编辑</h1> <el-form
<el-button type="text" size="small" @click="mode = 'table'">返回</el-button> v-if="mode.includes('form')"
</form> ref="dataForm"
:model="dataForm"
size="small"
style="padding: 16px"
v-loading="formLoading">
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="订单号" prop="orderCode" :rules="null">
<el-input v-model="dataForm.orderCode" disabled placeholder="-" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="订单子号" prop="orderCate" :rules="null">
<el-input v-model="dataForm.orderCate" disabled placeholder="-" />
</el-form-item>
</el-col>
<el-col :span="8">
<!-- 总量 - 前端计算 -->
<el-form-item label="生产总量" prop="qty" :rules="null">
<el-input v-model="dataForm.qty" disabled placeholder="-" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="合格砖数量" prop="goodqty" :rules="[$fv.isRequired, $fv.isNumber]">
<el-input v-model="dataForm.goodqty" placeholder="请输入合格砖数量" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="报废砖数量" prop="badqty" :rules="[$fv.isRequired, $fv.isNumber]">
<el-input v-model="dataForm.badqty" placeholder="请输入报废砖数量" />
</el-form-item>
</el-col>
<el-col :span="8">
<!-- 报废率 - 前端计算 -->
<el-form-item label="报废率" prop="badratio" :rules="null">
<el-input v-model="dataForm.badratio" disabled placeholder="-" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="报工班次" prop="team" :rules="null">
<el-input v-model="dataForm.team" placeholder="请输入报工班次" />
</el-form-item>
</el-col>
<el-col :span="8" style="padding-top: 32px">
<el-button type="primary" size="small" @click="handleSaveEdit">预保存</el-button>
<el-button size="small" @click="mode = 'table'">取消</el-button>
</el-col>
</el-row>
</el-form>
</transition> </transition>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button size="small" @click="close">取消</el-button> <el-button size="small" @click="close">取消</el-button>
<el-button size="small" type="primary" @click="handleConfirm">确定</el-button> <el-button size="small" type="primary" @click="handleConfirm">提交更改</el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
@ -53,6 +113,18 @@ export default {
loading: false, loading: false,
dataList: [], dataList: [],
page: 1, page: 1,
dataForm: {
id: null,
orderCate: null,
orderCode: null,
qty: null,
goodqty: null,
badqty: null,
badratio: null,
team: null,
},
formLoading: false,
dataFormList: [],
tableProps: [ tableProps: [
{ prop: "orderCode", label: "订单号" }, { prop: "orderCode", label: "订单号" },
{ prop: "orderCate", label: "订单子号" }, { prop: "orderCate", label: "订单子号" },
@ -73,7 +145,7 @@ export default {
width: 90, width: 90,
subcomponent: TableOperaionComponent, subcomponent: TableOperaionComponent,
options: [ options: [
{ name: "edit", label: "编辑", icon: "edit-outline" }, { name: "edit", label: "编辑", icon: "edit-outline", emitFull: true },
// { // {
// name: "delete", // name: "delete",
// icon: "delete", // icon: "delete",
@ -84,6 +156,7 @@ export default {
], ],
}, },
], ],
currentEditing: null,
}; };
}, },
computed: { computed: {
@ -91,6 +164,18 @@ export default {
return this.dataList.length; return this.dataList.length;
}, },
}, },
watch: {
"dataForm.goodqty"(val) {
const qty = +val + +this.dataForm.badqty;
this.dataForm.qty = qty;
this.dataForm.badratio = ((+this.dataForm.badqty / qty) * 100).toFixed(2);
},
"dataForm.badqty"(val) {
const qty = +val + +this.dataForm.goodqty;
this.dataForm.qty = qty;
this.dataForm.badratio = ((+val / qty) * 100).toFixed(2);
},
},
methods: { methods: {
async init() { async init() {
this.visible = true; this.visible = true;
@ -100,32 +185,87 @@ export default {
ids: this.ids, ids: this.ids,
}); });
if (res.code === 0) { if (res.code === 0) {
this.dataList = res.data.map((item) => ({ this.dataList = res.data.map((item, index) => ({
...item, ...item,
qty: item.goodqty + item.badqty, qty: item.goodqty + item.badqty,
// __LOCAL_INDEX
__LOCAL_INDEX: index,
})); }));
console.log("this.datalist", this.dataList);
} }
this.loading = false; this.loading = false;
}, },
close() { close() {
this.visible = false; this.visible = false;
}, },
handleOperate({ type, data }) { handleOperate({ type, data }) {
console.log("payload", type, data); console.log("payload", type, data);
switch (type) { switch (type) {
case "edit": case "edit":
this.mode = "form"; this.mode = "form";
this.currentEditing = data.__LOCAL_INDEX;
const { id, orderCate, orderCode, qty, goodqty, badqty, badratio, team } = data;
this.dataForm = {
id,
orderCate,
orderCode,
qty,
goodqty,
badqty,
badratio,
team,
};
break; break;
} }
}, },
handleConfirm() {},
async handleConfirm() {
this.loading = true;
const { data: res } = await this.$http.post("/pms/workReport/pressReport", {
datas: this.dataList,
ids: this.ids,
});
this.loading = false;
if (res.code === 0) {
this.$message.success("提交成功");
this.$emit('refresh-list')
this.close();
}
},
//
handleSaveEdit() {
Object.keys(this.dataForm).forEach((key) => {
this.dataList[this.currentEditing][key] = this.dataForm[key];
});
this.mode = "table";
this.$nextTick(() => {
this.clearDataForm();
});
},
//
clearDataForm() {
this.currentEditing = null;
this.dataForm = {
id: null,
orderCate: null,
orderCode: null,
qty: null,
goodqty: null,
badqty: null,
badratio: null,
team: null,
};
},
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.dialog-just-form >>> .dialog-title { .dialog-just-form >>> .dialog-title {
color: #000;
} }
.dialog-just-form >>> .el-dialog__body { .dialog-just-form >>> .el-dialog__body {

View File

@ -23,7 +23,8 @@ import { hasPermission, getDictLabel } from '@/utils'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
// main.js // main.js
import myComponents from 'code-brick-zj' import myComponents from 'code-brick-zj'
// 表单验证
import { formValidateRules } from '@/utils/validate'
// import mocks from './mocks' // import mocks from './mocks'
@ -44,6 +45,7 @@ Vue.use(myComponents)
Vue.prototype.$http = http Vue.prototype.$http = http
Vue.prototype.$hasPermission = hasPermission Vue.prototype.$hasPermission = hasPermission
Vue.prototype.$getDictLabel = getDictLabel Vue.prototype.$getDictLabel = getDictLabel
Vue.prototype.$fv = formValidateRules
// 保存整站vuex本地储存初始状态 // 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state) window.SITE_CONFIG['storeState'] = cloneDeep(store.state)

View File

@ -2,30 +2,47 @@
* 邮箱 * 邮箱
* @param {*} s * @param {*} s
*/ */
export function isEmail (s) { export function isEmail(s) {
return /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s) return /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s);
} }
/** /**
* 手机号码 * 手机号码
* @param {*} s * @param {*} s
*/ */
export function isMobile (s) { export function isMobile(s) {
return /^1[0-9]{10}$/.test(s) return /^1[0-9]{10}$/.test(s);
} }
/** /**
* 电话号码 * 电话号码
* @param {*} s * @param {*} s
*/ */
export function isPhone (s) { export function isPhone(s) {
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s) return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s);
} }
/** /**
* URL地址 * URL地址
* @param {*} s * @param {*} s
*/ */
export function isURL (s) { export function isURL(s) {
return /^http[s]?:\/\/.*/.test(s) return /^http[s]?:\/\/.*/.test(s);
} }
/**
* 表单验证
*/
export const formValidateRules = {
isRequired: {
required: true,
message: "必填项",
trigger: "blur",
},
isNumber: {
type: "number",
message: "请输入正确的数字类型",
trigger: "blur",
transform: (val) => Number(val),
},
};

View File

@ -68,6 +68,7 @@
ref="car-report-dialog" ref="car-report-dialog"
v-if="carReportDialogVisible" v-if="carReportDialogVisible"
@destroy="carReportDialog = false" @destroy="carReportDialog = false"
@refresh-list="getList"
:ids="tableSelectedIds" /> :ids="tableSelectedIds" />
</div> </div>
</template> </template>