| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="isShow" |
| | | title="æ°å¢éè´éè´§" |
| | | width="1200" |
| | | @close="closeModal" |
| | | > |
| | | <el-form label-width="140px" :model="formState" label-position="top" ref="formRef" :inline="true"> |
| | | <el-form-item |
| | | label="éæåå·" |
| | | prop="no" |
| | | :rules="[ |
| | | { |
| | | required: !formState.isDefaultNo, |
| | | message: '请è¾å
¥éæåå·', |
| | | trigger: 'blur', |
| | | } |
| | | ]" |
| | | > |
| | | <el-input |
| | | v-model="formState.no" |
| | | :placeholder="formState.isDefaultNo ? '使ç¨ç³»ç»ç¼å·' : '请è¾å
¥éæåå·'" |
| | | :disabled="formState.isDefaultNo" |
| | | > |
| | | <template #append> |
| | | <el-checkbox v-model="formState.isDefaultNo" size="large" @change="handleChangeIsDefaultNo" /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="éè´§æ¹å¼" |
| | | prop="returnType" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©éè´§æ¹å¼', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select |
| | | v-model="formState.returnType" |
| | | placeholder="è¯·éæ©éè´§æ¹å¼" |
| | | style="width: 240px" |
| | | > |
| | | <el-option label="éè´§éæ¬¾" :value="0" /> |
| | | <el-option label="ææ¶" :value="1" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="ä¾åºååç§°" |
| | | prop="supplierId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©ä¾åºå', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select |
| | | v-model="formState.supplierId" |
| | | placeholder="è¯·éæ©ä¾åºå" |
| | | style="width: 240px" |
| | | @focus="fetchSupplierOptions" |
| | | @change="handleChangeSupplierId" |
| | | > |
| | | <el-option |
| | | v-for="item in supplierOptions" |
| | | :key="item.id" |
| | | :label="item.supplierName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="项ç®" |
| | | prop="projectId" |
| | | > |
| | | <el-select |
| | | v-model="formState.projectId" |
| | | placeholder="è¯·éæ©é¡¹ç®" |
| | | style="width: 240px" |
| | | @focus="fetchProjectOptions" |
| | | > |
| | | <el-option |
| | | v-for="item in projectOptions" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="项ç®é¶æ®µ" |
| | | prop="projectPhase" |
| | | > |
| | | <el-select |
| | | v-model="formState.projectPhase" |
| | | placeholder="è¯·éæ©é¡¹ç®é¶æ®µ" |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="item in projectStageOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="å¶ä½æ¥æ" |
| | | prop="preparedAt" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©å¶ä½æ¥æ', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-date-picker |
| | | v-model="formState.preparedAt" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="è¯·éæ©å¶ä½æ¥æ" |
| | | style="width: 240px" |
| | | clearable /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="å¶å人ï¼" |
| | | prop="preparedUserId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©å¶å人', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select |
| | | v-model="formState.preparedUserId" |
| | | placeholder="è¯·éæ©" |
| | | clearable |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | style="width: 240px" |
| | | @focus="fetchUserOptions" |
| | | > |
| | | <el-option |
| | | v-for="item in userOptions" |
| | | :key="item.userId" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="éæäººï¼" |
| | | prop="returnUserId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©éæäºº', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select |
| | | v-model="formState.returnUserId" |
| | | placeholder="è¯·éæ©" |
| | | clearable |
| | | filterable |
| | | default-first-option |
| | | style="width: 240px" |
| | | :reserve-keyword="false" |
| | | @focus="fetchUserOptions" |
| | | > |
| | | <el-option |
| | | v-for="item in userOptions" |
| | | :key="item.userId" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="éè´ååå·ï¼" |
| | | prop="purchaseLedgerId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: 'è¯·éæ©éè´ååå·', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select |
| | | v-model="formState.purchaseLedgerId" |
| | | placeholder="è¯·éæ©" |
| | | clearable |
| | | filterable |
| | | default-first-option |
| | | style="width: 240px" |
| | | :reserve-keyword="false" |
| | | @change="handleChangePurchaseLedgerId" |
| | | > |
| | | <el-option |
| | | v-for="item in purchaseLedgerOptions" |
| | | :key="item.id" |
| | | :label="item.purchaseContractNumber" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | label="夿³¨ï¼" |
| | | prop="remark" |
| | | > |
| | | <el-input v-model="formState.remark" type="textarea" placeholder="请è¾å
¥å¤æ³¨"/> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-button type="primary" size="small" @click="isShowProductsModal = true" :disabled="!formState.purchaseLedgerId">æ·»å 产å</el-button> |
| | | <el-table :data="products" border> |
| | | <el-table-column align="center" |
| | | type="selection" |
| | | width="55" /> |
| | | <el-table-column align="center" |
| | | label="åºå·" |
| | | type="index" |
| | | width="60" /> |
| | | <el-table-column label="产å大类" |
| | | prop="productCategory" /> |
| | | <el-table-column label="è§æ ¼åå·" |
| | | prop="specificationModel" /> |
| | | <el-table-column label="åä½" |
| | | prop="unit" |
| | | width="70" /> |
| | | <el-table-column label="æ°é" |
| | | prop="quantity" |
| | | width="70" /> |
| | | <el-table-column label="åºåé¢è¦æ°é" |
| | | prop="warnNum" |
| | | width="120" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="ç¨ç(%)" |
| | | prop="taxRate" |
| | | width="80" /> |
| | | <el-table-column label="å«ç¨åä»·(å
)" |
| | | prop="taxInclusiveUnitPrice" |
| | | :formatter="formattedNumber" |
| | | width="150" /> |
| | | <el-table-column label="å«ç¨æ»ä»·(å
)" |
| | | prop="taxInclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | width="150" /> |
| | | <el-table-column label="ä¸å«ç¨æ»ä»·(å
)" |
| | | prop="taxExclusiveTotalPrice" |
| | | :formatter="formattedNumber" |
| | | width="150" /> |
| | | <el-table-column label="æ¯å¦è´¨æ£" |
| | | prop="isChecked" |
| | | width="150"> |
| | | <template #default="scope"> |
| | | <el-tag :type="scope.row.isChecked ? 'success' : 'info'"> |
| | | {{ scope.row.isChecked ? 'æ¯' : 'å¦' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" |
| | | label="æä½" |
| | | width="120" |
| | | align="center"> |
| | | <template #default="scope"> |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | size="small" |
| | | > |
| | | ç¼è¾ |
| | | </el-button> |
| | | <el-button |
| | | link |
| | | type="danger" |
| | | size="small" |
| | | @click="delProduct(scope.$index)" |
| | | > |
| | | å é¤ |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="handleSubmit">确认</el-button> |
| | | <el-button @click="closeModal">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | |
| | | <ProductList |
| | | v-if="isShowProductsModal" |
| | | v-model:visible="isShowProductsModal" |
| | | :purchase-ledger-id="formState.purchaseLedgerId" |
| | | @completed="handleAddProduct" |
| | | /> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, computed, getCurrentInstance} from "vue"; |
| | | import {createPurchaseReturnOrder} from "@/api/procurementManagement/purchase_return_order.js"; |
| | | import {getOptions, purchaseList} from "@/api/procurementManagement/procurementLedger.js"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | const ProductList = defineAsyncComponent(() => import("@/views/procurementManagement/purchaseReturnOrder/ProductList.vue")); |
| | | const props = defineProps({ |
| | | visible: { |
| | | type: Boolean, |
| | | required: true, |
| | | } |
| | | }); |
| | | let { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['update:visible', 'completed']); |
| | | |
| | | // ååºå¼æ°æ®ï¼æ¿ä»£é项å¼ç dataï¼ |
| | | const formState = ref({ |
| | | no: '', |
| | | isDefaultNo: true, |
| | | returnType: 0, |
| | | remark: '', |
| | | supplierId: undefined, |
| | | projectId: undefined, |
| | | projectPhase: undefined, |
| | | preparedAt: undefined, |
| | | preparedUserId: undefined, |
| | | returnUserId: undefined, |
| | | purchaseLedgerId: undefined, |
| | | }); |
| | | // ä¾åºåé项 |
| | | const supplierOptions = ref([]) |
| | | // 项ç®é项 |
| | | const projectOptions = ref([]) |
| | | // 项ç®é¶æ®µé项 |
| | | const projectStageOptions = ref([ |
| | | { |
| | | label: 'ç«é¡¹', |
| | | value: 0, |
| | | }, |
| | | { |
| | | label: '设计', |
| | | value: 1, |
| | | }, |
| | | { |
| | | label: 'éè´', |
| | | value: 2, |
| | | }, |
| | | { |
| | | label: 'ç产', |
| | | value: 3, |
| | | }, |
| | | { |
| | | label: 'åºè´§', |
| | | value: 4, |
| | | } |
| | | ]) |
| | | // ç¨æ·é项 |
| | | const userOptions = ref([]) |
| | | // éè´å°è´¦é项 |
| | | const purchaseLedgerOptions = ref([]) |
| | | // 产ååè¡¨æ°æ® |
| | | const products = ref([]) |
| | | // æ¯å¦å±ç¤ºäº§ååè¡¨æ°æ® |
| | | const isShowProductsModal = ref(false) |
| | | |
| | | const isShow = computed({ |
| | | get() { |
| | | return props.visible; |
| | | }, |
| | | set(val) { |
| | | emit('update:visible', val); |
| | | }, |
| | | }); |
| | | |
| | | const formattedNumber = (row, column, cellValue) => { |
| | | return parseFloat(cellValue).toFixed(2); |
| | | }; |
| | | |
| | | const closeModal = () => { |
| | | isShow.value = false; |
| | | }; |
| | | |
| | | // è·åä¾åºåé项 |
| | | const fetchSupplierOptions = () => { |
| | | if (supplierOptions.value.length > 0) { |
| | | return |
| | | } |
| | | getOptions().then((res) => { |
| | | supplierOptions.value = res.data; |
| | | }); |
| | | } |
| | | |
| | | // è·å项ç®é项 |
| | | const fetchProjectOptions = () => { |
| | | if (projectOptions.value.length > 0) { |
| | | return |
| | | } |
| | | // todo 项ç®é项 |
| | | } |
| | | |
| | | // è·åç¨æ·é项 |
| | | const fetchUserOptions = () => { |
| | | if (userOptions.value.length > 0) { |
| | | return |
| | | } |
| | | userListNoPageByTenantId().then((res) => { |
| | | userOptions.value = res.data; |
| | | }); |
| | | } |
| | | |
| | | // å¤çæ¹åä¾åºåæ°æ® |
| | | const handleChangeSupplierId = () => { |
| | | formState.value.purchaseLedgerId = undefined |
| | | fetchPurchaseLedgerOptions() |
| | | } |
| | | |
| | | // è·åéè´å°è´¦é项 |
| | | const fetchPurchaseLedgerOptions = () => { |
| | | purchaseLedgerOptions.value = [] |
| | | if (formState.value.supplierId) { |
| | | purchaseList({supplierId: formState.value.supplierId}).then((res) => { |
| | | purchaseLedgerOptions.value = res.rows; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // å¤çæ¹åéè´å°è´¦æ°æ® |
| | | const handleChangePurchaseLedgerId = () => { |
| | | products.value = [] |
| | | } |
| | | |
| | | // å¤çæ¹åæ¯å¦é»è®¤ç¼å· |
| | | const handleChangeIsDefaultNo = (checked) => { |
| | | if (checked) { |
| | | formState.value.no = '' |
| | | } |
| | | } |
| | | |
| | | // å¢å 产å |
| | | const handleAddProduct = (selectedRows) => { |
| | | products.value.push(...selectedRows) |
| | | } |
| | | |
| | | // å é¤å项产å |
| | | const delProduct = (index) => { |
| | | products.value.splice(index, 1) |
| | | } |
| | | |
| | | // æäº¤è¡¨å |
| | | const handleSubmit = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | createPurchaseReturnOrder(formState.value).then(res => { |
| | | // å
³éæ¨¡ææ¡ |
| | | isShow.value = false; |
| | | // åç¥ç¶ç»ä»¶å·²å®æ |
| | | emit('completed'); |
| | | proxy.$modal.msgSuccess("æäº¤æå"); |
| | | }) |
| | | } |
| | | }) |
| | | }; |
| | | |
| | | defineExpose({ |
| | | closeModal, |
| | | handleSubmit, |
| | | isShow, |
| | | }); |
| | | </script> |