|
@@ -0,0 +1,355 @@
|
|
|
+<template>
|
|
|
+ <div class="form" style="padding-bottom: 60px">
|
|
|
+ <van-nav-bar
|
|
|
+ :title="$t('purchased.name')"
|
|
|
+ :left-text="$t('common.back')"
|
|
|
+ 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.deptName"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ :label="$t('purchased.procurementDepartment')"
|
|
|
+ :placeholder="$t('purchased.selectProcurementDepartment')"
|
|
|
+ :rules="[{ required: true, message: $t('purchased.procurementDepartmentCanNotBeEmpty') }]"
|
|
|
+ :readonly="true"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseName"
|
|
|
+ type="text"
|
|
|
+ :name="$t('purchased.procurementPersonName')"
|
|
|
+ :label="$t('purchased.procurementPersonName')"
|
|
|
+ :placeholder="$t('purchased.pleaseFillInTheProcurementPersonName')"
|
|
|
+ :rules="[{ required: true, message: $t('purchased.procurementPersonNameCanNotBeEmpty') }]"
|
|
|
+ required
|
|
|
+ :readonly="true"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseTime"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ name="datePicker"
|
|
|
+ :label="$t('purchased.procurementTime')"
|
|
|
+ :placeholder="$t('purchased.clickToSelectTime')"
|
|
|
+
|
|
|
+
|
|
|
+ :rules="[{ required: true, message: $t('purchased.procurementTimeCanNotBeEmpty') }]"
|
|
|
+ required
|
|
|
+ :readonly="true"
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="timePicker" position="bottom">
|
|
|
+ <van-date-picker
|
|
|
+ @confirm="timeOnConfirm"
|
|
|
+ @cancel="timePicker = false"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <van-field
|
|
|
+ v-model="formData.supplyName"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ :label="$t('purchased.supplier')"
|
|
|
+ :placeholder="$t('purchased.selectSupplier')"
|
|
|
+ @click=" typeModal = true"
|
|
|
+ :rules="[{ required: true, message: $t('purchased.supplierCanNotBeEmpty') }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="typeModal" position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :title="$t('common.title')"
|
|
|
+ :columns="supplyList"
|
|
|
+ @confirm="onConfirm"
|
|
|
+ @cancel="typeModal = false"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseContent"
|
|
|
+ type="textarea"
|
|
|
+ :name="$t('purchased.procurementDescription')"
|
|
|
+ :label="$t('purchased.procurementDescription')"
|
|
|
+ :placeholder="$t('purchased.pleaseFillInTheProcurementDescription')"
|
|
|
+ rows="3"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ <!-- 明细列表 -->
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in formData.purchaseDetailList"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <div class="commons-delete">
|
|
|
+ <div class="title">{{$t('common.details')}}{{ 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.purchaseDetailList[index].productName"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ :label="$t('purchased.procurementProduct')"
|
|
|
+ :placeholder="$t('purchased.selectProcurementProduct')"
|
|
|
+ :readonly="true"
|
|
|
+ @click="handleSelect(index)"
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: $t('purchased.procurementProductCanNotBeEmpty') },
|
|
|
+ ]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+
|
|
|
+
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].count"
|
|
|
+ :name="$t('purchased.purchase')"
|
|
|
+ :label="$t('purchased.purchase')"
|
|
|
+ :placeholder="$t('purchased.pleaseEnterThePurchase')"
|
|
|
+ @change='changePrice(index)'
|
|
|
+ :rules="[{ required: true, message: $t('purchased.purchaseCanNotBeEmpty') }]"
|
|
|
+ required
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].price"
|
|
|
+ :name="$t('purchased.unitPrice')"
|
|
|
+ :label="$t('purchased.unitPrice')"
|
|
|
+ @change='changePrice(index)'
|
|
|
+ :placeholder="$t('purchased.pleaseEnterTheUnitPrice')"
|
|
|
+ :rules="[{ required: true, message: $t('purchased.unitPriceCanNotBeEmpty') }]"
|
|
|
+ required
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].amount"
|
|
|
+ :name="$t('purchased.totalPrice')"
|
|
|
+ :label="$t('purchased.totalPrice')"
|
|
|
+ :placeholder="$t('purchased.accordingToThePurchaseAndUnitPrice')"
|
|
|
+ :readonly="true"
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div class="commons-add-btn" v-if="!route.query.id">
|
|
|
+ <van-button
|
|
|
+ icon="plus"
|
|
|
+ type="default"
|
|
|
+
|
|
|
+ size="small"
|
|
|
+ style="margin-top: 10px"
|
|
|
+ block
|
|
|
+ @click="handleAddRow"
|
|
|
+ >{{$t('common.addDetails')}}</van-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <van-field
|
|
|
+ style="margin-top:16px"
|
|
|
+ v-model="formData.amount"
|
|
|
+ :name="$t('purchased.totalPrice')"
|
|
|
+ :label="$t('purchased.totalPrice')"
|
|
|
+ :placeholder="$t('purchased.theTotalAmountOfAllDetails')"
|
|
|
+ :readonly="true"
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="productModal" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="productData"
|
|
|
+ @cancel="productModal = false"
|
|
|
+ @confirm="(data) => onConfirmOne(data)"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <div style="margin: 16px" v-if="!route.query.id">
|
|
|
+ <van-button round block type="primary" native-type="submit">
|
|
|
+ {{$t('common.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'
|
|
|
+import { setUserInfo,setToken, getUserInfo,formatDate } from '@/utils/auth';
|
|
|
+const proxy = getCurrentInstance().proxy
|
|
|
+const route = useRoute()
|
|
|
+const typeModal = ref(false)
|
|
|
+const productModal = ref(false)
|
|
|
+let selectIndex = ref(null)
|
|
|
+const timePicker = ref(false)
|
|
|
+const userInfo = getUserInfo()
|
|
|
+const formData = ref({
|
|
|
+ deptName: userInfo.dept.deptName,
|
|
|
+ purchaseName: userInfo.nickName,
|
|
|
+ purchaseTime: formatDate(new Date(), 'yyyy-MM-dd'),
|
|
|
+ supplyId: '',
|
|
|
+ purchaseContent: '',
|
|
|
+ amount: '',
|
|
|
+ purchaseDetailList: [],
|
|
|
+})
|
|
|
+const handleAddRow = () => {
|
|
|
+ formData.value.purchaseDetailList.push({
|
|
|
+ bussinessId: '',
|
|
|
+ bussinessName: '',
|
|
|
+ name: '',
|
|
|
+ quantity: '',
|
|
|
+ content:"",
|
|
|
+ count:"",
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const supplyList = ref([])
|
|
|
+
|
|
|
+const timeOnConfirm = ({ selectedValues }) => {
|
|
|
+ formData.value.subcribeTime = selectedValues.join('-')
|
|
|
+ timePicker.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const getDict = () => {
|
|
|
+
|
|
|
+ proxy
|
|
|
+ .post('/supplierPrice/page', { pageNum: 1, pageSize: 9999 })
|
|
|
+ .then((res) => {
|
|
|
+ supplyList.value = res.data.rows.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ text: item.supplierName,
|
|
|
+ value: item.supplierInfoId,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(supplyList,12312312312312)
|
|
|
+ })
|
|
|
+
|
|
|
+ proxy
|
|
|
+ .post('/productInfo/page', { pageNum: 1, pageSize: 9999 })
|
|
|
+ .then((res) => {
|
|
|
+ productData.value = res.data.rows.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ text: item.name,
|
|
|
+ value: item.id,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//总价保留两位小数
|
|
|
+const changePrice = (index) => {
|
|
|
+ formData.value.purchaseDetailList[index].amount = (
|
|
|
+ formData.value.purchaseDetailList[index].count *
|
|
|
+ formData.value.purchaseDetailList[index].price
|
|
|
+ ).toFixed(2)
|
|
|
+ formData.value.amount = formData.value.purchaseDetailList.reduce(
|
|
|
+ (total, item) => {
|
|
|
+ return total + Number(item.amount)
|
|
|
+ },
|
|
|
+ 0
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const getDetails = (id) => {
|
|
|
+ proxy.post('/subscribe/detail', { id:id }).then((res) => {
|
|
|
+ res.data.subscribeDetailList.map((item) => {
|
|
|
+ productData.value.map((itemOne) => {
|
|
|
+ if(itemOne.value === item.bussinessId) {
|
|
|
+ item.bussinessName = itemOne.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ formData.value = res.data
|
|
|
+
|
|
|
+
|
|
|
+ console.log(formData.value)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const columns = ref([])
|
|
|
+const productData = ref([])
|
|
|
+const submitType = ref('add')
|
|
|
+
|
|
|
+const onConfirm = ({ selectedOptions }) => {
|
|
|
+ formData.value.supplyId = selectedOptions[0].value
|
|
|
+ formData.value.supplyName = selectedOptions[0].text
|
|
|
+ typeModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const onConfirmOne = ({ selectedOptions }) => {
|
|
|
+ formData.value.purchaseDetailList[selectIndex.value].bussinessId =
|
|
|
+ selectedOptions[0].value
|
|
|
+ formData.value.purchaseDetailList[selectIndex.value].productName =
|
|
|
+ selectedOptions[0].text
|
|
|
+ productModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const handleSelect = (index) => {
|
|
|
+ if(route.query.id) return
|
|
|
+ selectIndex.value = index
|
|
|
+ productModal.value = true
|
|
|
+}
|
|
|
+
|
|
|
+const handleDel = (index) => {
|
|
|
+ formData.value.subscribeDetailList.splice(index, 1)
|
|
|
+}
|
|
|
+
|
|
|
+const onClickLeft = () => history.back()
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ proxy.post('/flowProcess/initiate', {
|
|
|
+ flowKey: 'purchase_flow',
|
|
|
+ data:formData.value,
|
|
|
+ remark:null,
|
|
|
+ }).then(
|
|
|
+ (res) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ showSuccessToast(proxy.t('purchased.purchaseApplicationSuccessful'))
|
|
|
+ proxy.$router.push('/main/purchased')
|
|
|
+ }, 100)
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message)
|
|
|
+ }
|
|
|
+ )
|
|
|
+}
|
|
|
+const getDtl = (query) => {
|
|
|
+ proxy
|
|
|
+ .post('/purchase/detail', { id: query.id })
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res.data)
|
|
|
+ formData.value = res.data
|
|
|
+ })
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ console.log(route)
|
|
|
+ if (route.query.id) {
|
|
|
+ getDtl(route.query)
|
|
|
+ }
|
|
|
+ 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>
|