|
@@ -0,0 +1,247 @@
|
|
|
+<template>
|
|
|
+ <div class="form" style="padding-bottom: 60px">
|
|
|
+ <van-nav-bar
|
|
|
+ title="生产报工"
|
|
|
+ left-text="返回"
|
|
|
+ left-arrow
|
|
|
+ @click-left="onClickLeft"
|
|
|
+ >
|
|
|
+ </van-nav-bar>
|
|
|
+ <van-form @submit="onSubmit" label-align="top" style="margin-top: 20px">
|
|
|
+ <van-cell-group inset>
|
|
|
+ <van-field
|
|
|
+ v-model="formData.code"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ label="生产任务"
|
|
|
+ placeholder="选择生产任务"
|
|
|
+ @click="typeModal = true"
|
|
|
+ :rules="[{ required: true, message: '生产任务不能为空' }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="typeModal" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="columns"
|
|
|
+ @cancel="typeModal = false"
|
|
|
+ @confirm="onConfirm"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <van-field v-model="formData.productName" readonly label="产品名称" />
|
|
|
+ <van-field v-model="formData.quantity" readonly label="任务数量" />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.personLiableName"
|
|
|
+ readonly
|
|
|
+ label="负责人"
|
|
|
+ />
|
|
|
+ <van-field v-model="formData.dueDate" readonly label="完成期限" />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ <!-- 明细列表 -->
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in formData.productionReportingDetailList"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <div class="row">
|
|
|
+ <div class="title">明细{{ index + 1 }}</div>
|
|
|
+ <div
|
|
|
+ class="delete"
|
|
|
+ @click.native="handleDel(index)"
|
|
|
+ v-if="!route.query.id"
|
|
|
+ >
|
|
|
+ <van-icon name="cross" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <van-cell-group inset>
|
|
|
+ <van-field
|
|
|
+ v-model="
|
|
|
+ formData.productionReportingDetailList[index]
|
|
|
+ .productionProcessesName
|
|
|
+ "
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ label="工序名称"
|
|
|
+ placeholder="选择工序名称"
|
|
|
+ @click="handleSelect(index)"
|
|
|
+ :rules="[{ required: true, message: '工序名称不能为空' }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.productionReportingDetailList[index].name"
|
|
|
+ label="姓名"
|
|
|
+ placeholder="请输入姓名"
|
|
|
+ :rules="[{ required: true, message: '姓名不能为空' }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+
|
|
|
+ <van-field
|
|
|
+ v-model="formData.productionReportingDetailList[index].quantity"
|
|
|
+ label="报工数量"
|
|
|
+ placeholder="请输入报工数量"
|
|
|
+ :rules="[{ required: true, message: '报工数量不能为空' }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+ </div>
|
|
|
+ <van-popup v-model:show="typeModalOne" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="columnsOne"
|
|
|
+ @cancel="typeModalOne = false"
|
|
|
+ @confirm="(data) => onConfirmOne(data)"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+
|
|
|
+ <div style="text-align: center; line-height: 28px" v-if="!route.query.id">
|
|
|
+ <van-button
|
|
|
+ icon="plus"
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ size="mini"
|
|
|
+ style="margin-top: 10px"
|
|
|
+ @click="handleAddRow"
|
|
|
+ >添加明细</van-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="margin: 16px" v-if="!route.query.id">
|
|
|
+ <van-button round block type="primary" native-type="submit">
|
|
|
+ 提交
|
|
|
+ </van-button>
|
|
|
+ </div>
|
|
|
+ </van-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, getCurrentInstance, onMounted } from "vue";
|
|
|
+import { showSuccessToast, showFailToast } from "vant";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
+const route = useRoute();
|
|
|
+const typeModal = ref(false);
|
|
|
+const typeModalOne = ref(false);
|
|
|
+let selectIndex = ref(null);
|
|
|
+const formData = ref({
|
|
|
+ productionTaskId: "",
|
|
|
+ code: "",
|
|
|
+ productName: "",
|
|
|
+ quantity: "",
|
|
|
+ personLiableName: "",
|
|
|
+ dueDate: "",
|
|
|
+ productionReportingDetailList: [],
|
|
|
+});
|
|
|
+const handleAddRow = () => {
|
|
|
+ formData.value.productionReportingDetailList.push({
|
|
|
+ productionProcessesId: "",
|
|
|
+ productionProcessesName: "",
|
|
|
+ name: "",
|
|
|
+ quantity: "",
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const getDict = () => {
|
|
|
+ proxy
|
|
|
+ .post("/productionTask/page", { pageNum: 1, pageSize: 9999 })
|
|
|
+ .then((res) => {
|
|
|
+ columns.value = res.data.rows.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ text: item.code,
|
|
|
+ value: item.id,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ proxy
|
|
|
+ .post("/productionProcesses/page", { pageNum: 1, pageSize: 9999 })
|
|
|
+ .then((res) => {
|
|
|
+ columnsOne.value = res.data.rows.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ text: item.name,
|
|
|
+ value: item.id,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const getDetails = (id) => {
|
|
|
+ proxy.post("/productionReporting/detail", { id }).then((res) => {
|
|
|
+ res.data.productionReportingDetailList = [
|
|
|
+ ...res.data.productionReportingDetailVoList,
|
|
|
+ ];
|
|
|
+ formData.value = res.data;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const columns = ref([]);
|
|
|
+const columnsOne = ref([]);
|
|
|
+
|
|
|
+const onConfirm = ({ selectedOptions }) => {
|
|
|
+ formData.value.code = selectedOptions[0].text;
|
|
|
+ formData.value.productionTaskId = selectedOptions[0].value;
|
|
|
+ formData.value.productName = selectedOptions[0].productName;
|
|
|
+ formData.value.quantity = selectedOptions[0].quantity;
|
|
|
+ formData.value.personLiableName = selectedOptions[0].personLiableName;
|
|
|
+ formData.value.dueDate = selectedOptions[0].dueDate;
|
|
|
+ typeModal.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+const onConfirmOne = ({ selectedOptions }) => {
|
|
|
+ formData.value.productionReportingDetailList[
|
|
|
+ selectIndex.value
|
|
|
+ ].productionProcessesId = selectedOptions[0].value;
|
|
|
+ formData.value.productionReportingDetailList[
|
|
|
+ selectIndex.value
|
|
|
+ ].productionProcessesName = selectedOptions[0].text;
|
|
|
+ typeModalOne.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+const handleSelect = (index) => {
|
|
|
+ selectIndex.value = index;
|
|
|
+ typeModalOne.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleDel = (index) => {
|
|
|
+ formData.value.productionReportingDetailList.splice(index, 1);
|
|
|
+};
|
|
|
+
|
|
|
+const onClickLeft = () => history.back();
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ if (!formData.value.productionReportingDetailList.length > 0)
|
|
|
+ return showFailToast("请添加明细!");
|
|
|
+ proxy.post("/productionReporting/add", formData.value).then(
|
|
|
+ (res) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ showSuccessToast("报工成功");
|
|
|
+ proxy.$router.push("/main/reportWork");
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message);
|
|
|
+ }
|
|
|
+ );
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ getDetails(route.query.id);
|
|
|
+ getDict();
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.row {
|
|
|
+ display: flex;
|
|
|
+ padding: 5px 15px;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ color: #999999;
|
|
|
+ .title {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+ .delete {
|
|
|
+ width: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|