cz 1 year ago
parent
commit
a76724ebd9

+ 7 - 2
src/router/index.js

@@ -91,7 +91,7 @@ const routes = [{
 				name: '流程办理-详情',
 				component: () => import('../views/processApproval/processDtl.vue')
 			},
-			
+
 			//公共模块
 			{
 				path: 'contractTemplateAdd',
@@ -303,6 +303,11 @@ const routes = [{
 				component: () => import('../views/procurementManagement/purchased/index.vue')
 			},
 			{
+				path: 'purchasedOne',
+				name: '采购合同',
+				component: () => import('../views/procurementManagement/purchasedOne/index.vue')
+			},
+			{
 				path: 'purchasedAdd',
 				name: '已采购详情',
 				component: () => import('../views/procurementManagement/purchased/add.vue')
@@ -519,7 +524,7 @@ const routes = [{
 				name: "开发中",
 				component: () => import("../views/home/coming.vue"),
 			},
-			
+
 		]
 	},
 ]

+ 355 - 0
src/views/procurementManagement/purchasedOne/add.vue

@@ -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>

+ 144 - 0
src/views/procurementManagement/purchasedOne/index.vue

@@ -0,0 +1,144 @@
+<template>
+  <van-nav-bar :title="'采购合同'" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
+    <!-- <template #right> {{$t('purchased.addProcurement')}} </template> -->
+  </van-nav-bar>
+  <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
+  <van-pull-refresh v-model="loading" @refresh="onRefresh">
+    <div class="list">
+      <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
+        <commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
+      </van-list>
+    </div>
+  </van-pull-refresh>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted } from "vue";
+import commonList from "@/components/common-list.vue";
+import { useRoute } from "vue-router";
+const loading = ref(false);
+const router = useRoute();
+const req = ref({
+  pageNum: 1,
+  keyword: "",
+  status: "",
+  payStatus: "",
+});
+const finished = ref(false);
+const proxy = getCurrentInstance().proxy;
+const listData = ref([]);
+
+const listConfig = ref([
+  {
+    label: "采购单号",
+    prop: "code",
+  },
+  {
+    label: proxy.t("purchased.supplier"),
+    prop: "supplyName",
+  },
+  {
+    label: proxy.t("purchased.purchaseAmount"),
+    prop: "amount",
+  },
+  {
+    label: "采购人",
+    prop: "userName",
+  },
+  {
+    label: "采购状态",
+    prop: "statusName",
+  },
+]);
+const onRefresh = () => {
+  req.value.pageNum = 1;
+  finished.value = false;
+  getList("refresh");
+};
+const onLoad = () => {
+  getList();
+};
+
+const onClickLeft = () => proxy.$router.push("/main/working");
+
+const onClickRight = () => {
+  proxy.$router.push("/main/purchasedAdd");
+};
+proxy.uploadDdRightBtn(onClickRight, "新增采购");
+const toDtl = (row) => {
+  proxy.$router.push({
+    path: "/main/processDtl",
+    query: {
+      flowKey: "ehsd_purchase_flow",
+      id: row.flowId,
+      processType: 20,
+      businessId: row.id,
+    },
+  });
+};
+
+const status = ref([
+  {
+    label: "草稿",
+    value: 0,
+  },
+  {
+    label: "审批中",
+    value: 10,
+  },
+  {
+    label: "驳回",
+    value: 20,
+  },
+  {
+    label: "已采购",
+    value: 30,
+  },
+  {
+    label: "变更中",
+    value: 60,
+  },
+  {
+    label: "已变更",
+    value: 70,
+  },
+  {
+    label: "作废",
+    value: 88,
+  },
+  {
+    label: "终止",
+    value: 99,
+  },
+]);
+
+const getList = (type) => {
+  loading.value = true;
+  proxy
+    .post("/ehsdPurchase/page", req.value)
+    .then((res) => {
+      console.log(req.value);
+      res.data.rows.map((item) => {
+        item.statusName = proxy.dictValueLabel(item.status, status.value);
+      });
+      listData.value =
+        type === "refresh"
+          ? res.data.rows
+          : listData.value.concat(res.data.rows);
+      if (req.value.pageNum * 10 >= res.data.total) {
+        finished.value = true;
+      }
+      req.value.pageNum++;
+      loading.value = false;
+    })
+    .catch((err) => {
+      loading.value = false;
+    });
+};
+getList();
+</script>
+
+<style lang="scss" scoped>
+.list {
+  min-height: 70vh;
+}
+</style>