|
@@ -0,0 +1,364 @@
|
|
|
+<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.deptName"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ label="申购部门"
|
|
|
+ placeholder="选择申购部门"
|
|
|
+ :rules="[{ required: true, message: '申购部门不能为空' }]"
|
|
|
+ :readonly="true"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseName"
|
|
|
+ type="text"
|
|
|
+ name="申购人名称"
|
|
|
+ label="申购人名称"
|
|
|
+ placeholder="请填写申购人名称"
|
|
|
+ :rules="[{ required: true, message: '申购人名称不能为空' }]"
|
|
|
+ required
|
|
|
+ :readonly="true"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseTime"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ name="datePicker"
|
|
|
+ label="申购时间"
|
|
|
+ placeholder="点击选择时间"
|
|
|
+
|
|
|
+
|
|
|
+ :rules="[{ required: true, message: '申购时间不能为空' }]"
|
|
|
+ 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="供应商"
|
|
|
+ placeholder="选择供应商"
|
|
|
+ @click=" typeModal = true"
|
|
|
+ :rules="[{ required: true, message: '供应商不能为空' }]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="typeModal" position="bottom">
|
|
|
+ <van-picker
|
|
|
+ title="标题"
|
|
|
+ :columns="supplyList"
|
|
|
+ @confirm="onConfirm"
|
|
|
+ @cancel="typeModal = false"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseContent"
|
|
|
+ type="textarea"
|
|
|
+ name="申购说明"
|
|
|
+ label="申购说明"
|
|
|
+ placeholder="请填写申购说明"
|
|
|
+ :rules="[{ required: true, message: '申购说明不能为空' }]"
|
|
|
+ required
|
|
|
+ rows="3"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ <!-- 明细列表 -->
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in formData.purchaseDetailList"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <div class="commons-delete">
|
|
|
+ <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.purchaseDetailList[index].productName
|
|
|
+ "
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ label="申购产品"
|
|
|
+ placeholder="选择申购产品"
|
|
|
+ :readonly="true"
|
|
|
+
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: '申购产品不能为空' },
|
|
|
+ ]"
|
|
|
+ required
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].count2"
|
|
|
+ label="数量"
|
|
|
+ placeholder="请输入数量"
|
|
|
+ :rules="[{ required: true, message: '数量不能为空' }]"
|
|
|
+ required
|
|
|
+ type="number"
|
|
|
+ :readonly="true"
|
|
|
+ />
|
|
|
+
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].count"
|
|
|
+ name="本次采购"
|
|
|
+ label="本次采购"
|
|
|
+ placeholder="请输入"
|
|
|
+ @change='changePrice(index)'
|
|
|
+ :rules="[{ required: true, message: '本次采购不能为空' }]"
|
|
|
+ required
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].price"
|
|
|
+ name="单价"
|
|
|
+ label="单价"
|
|
|
+ @change='changePrice(index)'
|
|
|
+ placeholder="请输入"
|
|
|
+ :rules="[{ required: true, message: '单价不能为空' }]"
|
|
|
+ required
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="formData.purchaseDetailList[index].amount"
|
|
|
+ name="总价"
|
|
|
+ label="总价"
|
|
|
+ placeholder="根据本次采购和单价自动计算"
|
|
|
+ :readonly="true"
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <van-field
|
|
|
+ style="margin-top:16px"
|
|
|
+ v-model="formData.amount"
|
|
|
+ name="总价"
|
|
|
+ label="总价"
|
|
|
+ placeholder="所有明细的金额合计"
|
|
|
+ :readonly="true"
|
|
|
+ type="number"
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="typeModalOne" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="columnsOne"
|
|
|
+ @cancel="typeModalOne = 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">
|
|
|
+ 提交
|
|
|
+ </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 typeModalOne = 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.subscribeDetailList.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) => {
|
|
|
+ columnsOne.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) => {
|
|
|
+ columnsOne.value.map((itemOne) => {
|
|
|
+ if(itemOne.value === item.bussinessId) {
|
|
|
+ item.bussinessName = itemOne.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ formData.value = res.data
|
|
|
+
|
|
|
+
|
|
|
+ console.log(formData.value)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const columns = ref([])
|
|
|
+const columnsOne = 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.subscribeDetailList[selectIndex.value].bussinessId =
|
|
|
+ selectedOptions[0].value
|
|
|
+ formData.value.subscribeDetailList[selectIndex.value].bussinessName =
|
|
|
+ selectedOptions[0].text
|
|
|
+ typeModalOne.value = false
|
|
|
+}
|
|
|
+
|
|
|
+const handleSelect = (index) => {
|
|
|
+ if(submitType.value === 'edit') return
|
|
|
+ selectIndex.value = index
|
|
|
+ typeModalOne.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.$router.push('/main/procureList')
|
|
|
+ }, 100)
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message)
|
|
|
+ }
|
|
|
+ )
|
|
|
+}
|
|
|
+const getDtl = (query) => {
|
|
|
+ proxy
|
|
|
+ .post('/subscribeDetail/detail', { ids: JSON.parse(query.ids) })
|
|
|
+ .then((res) => {
|
|
|
+ formData.value.purchaseDetailList = res.data.map((item) => {
|
|
|
+ return {
|
|
|
+
|
|
|
+ bussinessId: item.bussinessId,
|
|
|
+ productName: item.productName,
|
|
|
+ count2: item.count,
|
|
|
+ subscribeDetailId: item.id,
|
|
|
+ count:null,
|
|
|
+ content:null,
|
|
|
+ price:null,
|
|
|
+ amount:null,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ console.log(route)
|
|
|
+ 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>
|