| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // ç产记å½ï¼åæ°ï¼æ¥å£ |
| | | import request from "@/utils/request"; |
| | | |
| | | // å页æ¥è¯¢ |
| | | export function listPage(query) { |
| | | return request({ |
| | | url: "/productParameter/listPage", |
| | | method: "get", |
| | | params: query, |
| | | }); |
| | | } |
| | | |
| | | // æ°å¢ |
| | | export function add(data) { |
| | | return request({ |
| | | url: "/productParameter/addProductParameter", |
| | | method: "post", |
| | | data: data, |
| | | }); |
| | | } |
| | | |
| | | // ä¿®æ¹ |
| | | export function update(data) { |
| | | return request({ |
| | | url: "/productParameter/updProductParameter", |
| | | method: "put", |
| | | data: data, |
| | | }); |
| | | } |
| | | |
| | | // å é¤ ids 为æ°ç»æ¶ä¼æ¼æ productParameter/1,2,3 |
| | | export function del(ids) { |
| | | const idStr = Array.isArray(ids) ? ids.join(",") : ids; |
| | | return request({ |
| | | url: `/productParameter/${idStr}`, |
| | | method: "delete", |
| | | }); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="isShow" |
| | | title="ç¼è¾ç产记å½" |
| | | width="520px" |
| | | @close="closeModal" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | label-width="120px" |
| | | :model="formState" |
| | | label-position="top" |
| | | > |
| | | <el-form-item |
| | | label="忰项" |
| | | prop="parameterItem" |
| | | :rules="[{ required: true, message: '请è¾å
¥åæ°é¡¹' }]" |
| | | > |
| | | <el-input v-model="formState.parameterItem" placeholder="请è¾å
¥åæ°é¡¹" /> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="åæ°ç±»å" |
| | | prop="type" |
| | | :rules="[{ required: true, message: 'è¯·éæ©åæ°ç±»å' }]" |
| | | > |
| | | <el-select v-model="formState.type" placeholder="è¯·éæ©åæ°ç±»å" style="width: 100%;"> |
| | | <el-option |
| | | v-for="dict in parameter_tyep" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="åä½" |
| | | prop="unit" |
| | | :rules="[{ required: true, message: '请è¾å
¥åä½' }]" |
| | | > |
| | | <el-input v-model="formState.unit" placeholder="请è¾å
¥åä½" /> |
| | | </el-form-item> |
| | | <el-form-item label="åæ°æ ¼å¼" prop="parameterFormat"> |
| | | <el-input v-model="formState.parameterFormat" placeholder="请è¾å
¥åæ°æ ¼å¼ï¼éå¡«ï¼" /> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="æ¯å¦å¿
å¡«" |
| | | prop="isRequired" |
| | | :rules="[{ required: true, message: 'è¯·éæ©æ¯å¦å¿
å¡«' }]" |
| | | > |
| | | <el-select v-model="formState.isRequired" placeholder="è¯·éæ©" style="width: 100%;"> |
| | | <el-option label="æ¯" value="1" /> |
| | | <el-option label="å¦" value="0" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="handleSubmit">确认</el-button> |
| | | <el-button @click="closeModal">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, computed, getCurrentInstance, watch } from "vue"; |
| | | import { update } from "@/api/productionManagement/productionRecords.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | | type: Boolean, |
| | | required: true, |
| | | }, |
| | | record: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["update:visible", "completed"]); |
| | | |
| | | const formRef = ref(null); |
| | | const formState = ref({ |
| | | id: undefined, |
| | | code: "", |
| | | parameterItem: "", |
| | | type: "", |
| | | unit: "", |
| | | parameterFormat: "", |
| | | isRequired: undefined, |
| | | }); |
| | | |
| | | const isShow = computed({ |
| | | get() { |
| | | return props.visible; |
| | | }, |
| | | set(val) { |
| | | emit("update:visible", val); |
| | | }, |
| | | }); |
| | | |
| | | // åæ¾ï¼çå¬ record åå |
| | | watch( |
| | | () => props.record, |
| | | (newRecord) => { |
| | | if (newRecord && Object.keys(newRecord).length) { |
| | | formState.value = { |
| | | id: newRecord.id, |
| | | code: newRecord.code ?? "", |
| | | parameterItem: newRecord.parameterItem ?? "", |
| | | type: newRecord.type ?? "", |
| | | unit: newRecord.unit ?? "", |
| | | parameterFormat: newRecord.parameterFormat ?? "", |
| | | isRequired: newRecord.isRequired, |
| | | }; |
| | | } |
| | | }, |
| | | { immediate: true, deep: true } |
| | | ); |
| | | |
| | | // å¼¹çªæå¼æ¶éæ°åæ¾ |
| | | watch( |
| | | () => props.visible, |
| | | (visible) => { |
| | | if (visible && props.record && Object.keys(props.record).length) { |
| | | formState.value = { |
| | | id: props.record.id, |
| | | code: props.record.code ?? "", |
| | | parameterItem: props.record.parameterItem ?? "", |
| | | type: props.record.type ?? "", |
| | | unit: props.record.unit ?? "", |
| | | parameterFormat: props.record.parameterFormat ?? "", |
| | | isRequired: props.record.isRequired, |
| | | }; |
| | | } |
| | | } |
| | | ); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { parameter_tyep } = proxy.useDict("parameter_tyep"); |
| | | |
| | | const closeModal = () => { |
| | | isShow.value = false; |
| | | }; |
| | | |
| | | const handleSubmit = () => { |
| | | formRef.value.validate((valid) => { |
| | | if (valid) { |
| | | update(formState.value).then(() => { |
| | | isShow.value = false; |
| | | emit("completed"); |
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå"); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | closeModal, |
| | | handleSubmit, |
| | | isShow, |
| | | }); |
| | | </script> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="isShow" |
| | | title="æ°å¢ç产记å½" |
| | | width="520px" |
| | | @close="closeModal" |
| | | > |
| | | <el-form |
| | | ref="formRef" |
| | | label-width="120px" |
| | | :model="formState" |
| | | label-position="top" |
| | | > |
| | | <el-form-item |
| | | label="忰项" |
| | | prop="parameterItem" |
| | | :rules="[{ required: true, message: '请è¾å
¥åæ°é¡¹' }]" |
| | | > |
| | | <el-input v-model="formState.parameterItem" placeholder="请è¾å
¥åæ°é¡¹" /> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="åæ°ç±»å" |
| | | prop="type" |
| | | :rules="[{ required: true, message: 'è¯·éæ©åæ°ç±»å' }]" |
| | | > |
| | | <el-select v-model="formState.type" placeholder="è¯·éæ©åæ°ç±»å" style="width: 100%;"> |
| | | <el-option |
| | | v-for="dict in parameter_tyep" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="åä½" |
| | | prop="unit" |
| | | :rules="[{ required: true, message: '请è¾å
¥åä½' }]" |
| | | > |
| | | <el-input v-model="formState.unit" placeholder="请è¾å
¥åä½" /> |
| | | </el-form-item> |
| | | <el-form-item label="åæ°æ ¼å¼" prop="parameterFormat"> |
| | | <el-input v-model="formState.parameterFormat" placeholder="请è¾å
¥åæ°æ ¼å¼ï¼éå¡«ï¼" /> |
| | | </el-form-item> |
| | | <el-form-item |
| | | label="æ¯å¦å¿
å¡«" |
| | | prop="isRequired" |
| | | :rules="[{ required: true, message: 'è¯·éæ©æ¯å¦å¿
å¡«' }]" |
| | | > |
| | | <el-select v-model="formState.isRequired" placeholder="è¯·éæ©" style="width: 100%;"> |
| | | <el-option label="æ¯" value="1" /> |
| | | <el-option label="å¦" value="0" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="handleSubmit">确认</el-button> |
| | | <el-button @click="closeModal">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, computed, getCurrentInstance } from "vue"; |
| | | import { add } from "@/api/productionManagement/productionRecords.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | | type: Boolean, |
| | | required: true, |
| | | }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["update:visible", "completed"]); |
| | | |
| | | const formRef = ref(null); |
| | | const formState = ref({ |
| | | parameterItem: "", |
| | | type: "", |
| | | unit: "", |
| | | parameterFormat: "", |
| | | isRequired: undefined, |
| | | }); |
| | | |
| | | const isShow = computed({ |
| | | get() { |
| | | return props.visible; |
| | | }, |
| | | set(val) { |
| | | emit("update:visible", val); |
| | | }, |
| | | }); |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { parameter_tyep } = proxy.useDict("parameter_tyep"); |
| | | |
| | | const closeModal = () => { |
| | | isShow.value = false; |
| | | }; |
| | | |
| | | const handleSubmit = () => { |
| | | formRef.value.validate((valid) => { |
| | | if (valid) { |
| | | add(formState.value).then(() => { |
| | | isShow.value = false; |
| | | emit("completed"); |
| | | proxy.$modal.msgSuccess("æ°å¢æå"); |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | closeModal, |
| | | handleSubmit, |
| | | isShow, |
| | | }); |
| | | </script> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- çäº§è®°å½ --> |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <el-form :model="searchForm" :inline="true"> |
| | | <el-form-item label="åæ°ç¼ç :"> |
| | | <el-input |
| | | v-model="searchForm.code" |
| | | placeholder="请è¾å
¥" |
| | | clearable |
| | | style="width: 200px;" |
| | | @change="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="忰项:"> |
| | | <el-input |
| | | v-model="searchForm.parameterItem" |
| | | placeholder="请è¾å
¥" |
| | | clearable |
| | | style="width: 200px;" |
| | | @change="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="åæ°ç±»å:"> |
| | | <el-select |
| | | v-model="searchForm.type" |
| | | placeholder="è¯·éæ©" |
| | | clearable |
| | | style="width: 200px;" |
| | | @change="handleQuery" |
| | | > |
| | | <el-option |
| | | v-for="dict in parameter_tyep" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleQuery">æç´¢</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div class="table_list"> |
| | | <div style="text-align: right" class="mb10"> |
| | | <el-button type="primary" @click="showNewModal">æ°å¢</el-button> |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination" |
| | | :total="page.total" |
| | | /> |
| | | </div> |
| | | <NewRecord v-if="isShowNewModal" v-model:visible="isShowNewModal" @completed="getList" /> |
| | | <EditRecord |
| | | v-if="isShowEditModal" |
| | | v-model:visible="isShowEditModal" |
| | | :record="record" |
| | | @completed="getList" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue"; |
| | | import NewRecord from "./New.vue"; |
| | | import EditRecord from "./Edit.vue"; |
| | | import { listPage, del } from "@/api/productionManagement/productionRecords.js"; |
| | | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | code: "", |
| | | parameterItem: "", |
| | | type: "", |
| | | }, |
| | | }); |
| | | const { searchForm } = toRefs(data); |
| | | const { proxy } = getCurrentInstance(); |
| | | const { parameter_tyep } = proxy.useDict("parameter_tyep"); |
| | | |
| | | const tableColumn = ref([ |
| | | { label: "åæ°ç¼ç ", prop: "code" }, |
| | | { label: "忰项", prop: "parameterItem" }, |
| | | { |
| | | label: "åæ°ç±»å", |
| | | prop: "type", |
| | | formatData: (params) => |
| | | (parameter_tyep?.value ?? parameter_tyep ?? []).find((d) => String(d.value) === String(params))?.label ?? params, |
| | | }, |
| | | { label: "åä½", prop: "unit" }, |
| | | { label: "åæ°æ ¼å¼", prop: "parameterFormat" }, |
| | | { |
| | | label: "æ¯å¦å¿
å¡«", |
| | | prop: "isRequired", |
| | | formatData: (params) => (params === '1' ? "æ¯" : "å¦"), |
| | | }, |
| | | // { label: "å建人", prop: "createUser" }, |
| | | { label: "åå»ºæ¥æ", prop: "createTime" }, |
| | | // { label: "æ´æ°äºº", prop: "updateUser" }, |
| | | { label: "æ´æ°æ¥æ", prop: "updateTime" }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: "right", |
| | | width: 160, |
| | | operation: [ |
| | | { |
| | | name: "ç¼è¾", |
| | | type: "text", |
| | | clickFun: (row) => showEditModal(row), |
| | | }, |
| | | { |
| | | name: "å é¤", |
| | | type: "text", |
| | | clickFun: (row) => handleDeleteRow(row), |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const isShowNewModal = ref(false); |
| | | const isShowEditModal = ref(false); |
| | | const record = ref({}); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | total: 0, |
| | | }); |
| | | |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | |
| | | const pagination = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | const params = { ...searchForm.value, ...page }; |
| | | listPage(params) |
| | | .then((res) => { |
| | | tableLoading.value = false; |
| | | const data = res.data; |
| | | tableData.value = data?.records ?? (Array.isArray(data) ? data : []); |
| | | page.total = data?.total ?? 0; |
| | | }) |
| | | .catch(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | | |
| | | const showNewModal = () => { |
| | | isShowNewModal.value = true; |
| | | }; |
| | | |
| | | const showEditModal = (row) => { |
| | | record.value = { ...row }; |
| | | isShowEditModal.value = true; |
| | | }; |
| | | |
| | | const handleDeleteRow = (row) => { |
| | | proxy.$modal |
| | | .confirm(`æ¯å¦ç¡®è®¤å é¤åæ°ç¼ç 为"${row.code}"çæ°æ®ï¼`) |
| | | .then(() => del([row.id])) |
| | | .then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("å 餿å"); |
| | | }) |
| | | .catch(() => {}); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped></style> |