|
|
@@ -453,10 +453,12 @@
|
|
|
<Baseinfo :modeValue="deawerData" @close="handleBaseinfoClose" :baseType="form.taskType" />
|
|
|
</view>
|
|
|
</up-form-item>
|
|
|
- <up-form-item :borderBottom="false" label="具体位置" prop="baseId" id="baseIdpppp">
|
|
|
- <Go_button v-if="!laboratory" @click="openLaboratory" title="请选择具体位置" style="flex: 1" />
|
|
|
- <view class="w-100%" v-else>
|
|
|
- <laboratory :modeValue="laboratory" @close="handleLaboratoryClose" :baseType="form.taskType" />
|
|
|
+ <up-form-item :borderBottom="false" label="具体位置" prop="landLayers" id="landLayerspppp">
|
|
|
+ <Go_button @click="openLaboratory" title="请选择具体位置" style="flex: 1" />
|
|
|
+ <view class="w-100%" v-for="(it, indexs) in form?.landLayers" :key="indexs">
|
|
|
+ <view class="">{{ it?.layers }}</view>
|
|
|
+ <view class="">{{ stringifyCheckedList(it?.checkedList, Number(it?.capacityAmount || 0)) }}</view>
|
|
|
+ <view class="" @click="deleteLayer(indexs)">删除</view>
|
|
|
</view>
|
|
|
</up-form-item>
|
|
|
</view>
|
|
|
@@ -754,7 +756,7 @@
|
|
|
<view class="b-radius border-#A3E5EA c-#18BECA bg-#FAFFFF w-100% d-flex j-c a-c h-100 f-s-34">从种源库快速添加</view>
|
|
|
</view>
|
|
|
<up-swipe-action>
|
|
|
- <up-swipe-action-item class="mb-20" v-for="(item, index) in animalIds" :key="index" :index="item" :name="item" :options="options1" @click="clickSwipe">
|
|
|
+ <up-swipe-action-item class="mb-20" v-for="(item, index) in animalIds" :key="index" :index="item" :name="item" :options="options1" @click="clickSwipe">
|
|
|
<view class="b-radius border-#37A954 c-#333 f-s-28 pd4-34-30-34-30">{{ item }}</view>
|
|
|
</up-swipe-action-item>
|
|
|
</up-swipe-action>
|
|
|
@@ -828,7 +830,13 @@ const form = ref<PlantationTaskForm>({
|
|
|
inoculationDosageUnit: null,
|
|
|
cultureMediumFormula: null,
|
|
|
landFlag: null,
|
|
|
+ landLayers: [],
|
|
|
});
|
|
|
+const deleteLayer = (index) => {
|
|
|
+ if (form.value?.landLayers && Array.isArray(form.value.landLayers)) {
|
|
|
+ form.value.landLayers.splice(index, 1); // 删除当前索引的项
|
|
|
+ }
|
|
|
+};
|
|
|
const changeStartTime = () => {
|
|
|
if (!form.value?.queryType6?.plannedEndDate) {
|
|
|
form.value.queryType6.plannedEndDate = form.value.queryType6.plannedStartDate;
|
|
|
@@ -878,7 +886,60 @@ const handleAnimalIdCancel = () => {
|
|
|
editIndex.value = -1;
|
|
|
showAnimalIdDialog.value = false;
|
|
|
};
|
|
|
+const stringifyCheckedList = (list: any[], capacityAmount: number) => {
|
|
|
+ if (!list || list.length === 0) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ type ParsedItem = {
|
|
|
+ layer: number;
|
|
|
+ capacity: number;
|
|
|
+ value: string;
|
|
|
+ };
|
|
|
+ const parsed = list
|
|
|
+ .map((value) => {
|
|
|
+ const [layerText, capacityText] = String(value).split('-');
|
|
|
+ const layer = Number(layerText);
|
|
|
+ const capacity = Number(capacityText);
|
|
|
+ if (!layer || !capacity) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ layer,
|
|
|
+ capacity,
|
|
|
+ value: `${layer}-${capacity}`,
|
|
|
+ };
|
|
|
+ })
|
|
|
+ .filter((item): item is ParsedItem => item !== null)
|
|
|
+ .sort((left, right) => {
|
|
|
+ if (left.layer !== right.layer) {
|
|
|
+ return left.layer - right.layer;
|
|
|
+ }
|
|
|
+ return left.capacity - right.capacity;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!parsed.length) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
|
|
|
+ const segments: string[] = [];
|
|
|
+ let startIndex = 0;
|
|
|
+
|
|
|
+ for (let index = 1; index <= parsed.length; index++) {
|
|
|
+ const previous = parsed[index - 1]!;
|
|
|
+ const current = parsed[index];
|
|
|
+ const isSameLayerContinuous = !!current && current.layer === previous.layer && current.capacity === previous.capacity + 1;
|
|
|
+ const isCrossLayerContinuous = !!current && current.layer === previous.layer + 1 && previous.capacity === capacityAmount && current.capacity === 1;
|
|
|
+ const isContinuous = isSameLayerContinuous || isCrossLayerContinuous;
|
|
|
+ if (isContinuous) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const start = parsed[startIndex]!;
|
|
|
+ segments.push(start.value === previous.value ? start.value : `${start.value}至${previous.value}`);
|
|
|
+ startIndex = index;
|
|
|
+ }
|
|
|
+
|
|
|
+ return `${segments.join(',')}共${parsed.length}个位置`;
|
|
|
+};
|
|
|
// 扫一扫添加个体标识
|
|
|
const handleScanAdd = () => {
|
|
|
uni.scanCode({
|
|
|
@@ -1198,83 +1259,91 @@ const randomCode = async () => {
|
|
|
};
|
|
|
//完成提交表单
|
|
|
const save = () => {
|
|
|
- uni.$u.debounce(async () => {
|
|
|
- try {
|
|
|
- console.log('开始提交');
|
|
|
- await upFormRef.value?.validate();
|
|
|
- console.log('校验完成');
|
|
|
- if (+(form.value.delegateFlag ?? 0)) {
|
|
|
- form.value.delegateInfo.cusName = form.value?.delegate.cusName;
|
|
|
- form.value.delegateInfo.cusCode = form.value?.delegate.cusCode;
|
|
|
- } else {
|
|
|
- form.value.delegateInfo = null as any;
|
|
|
- form.value.delegate = null as any;
|
|
|
- }
|
|
|
+ uni.$u.debounce(
|
|
|
+ async () => {
|
|
|
+ try {
|
|
|
+ console.log('开始提交');
|
|
|
+ await upFormRef.value?.validate();
|
|
|
+ console.log('校验完成');
|
|
|
+ if (+(form.value.delegateFlag ?? 0)) {
|
|
|
+ form.value.delegateInfo.cusName = form.value?.delegate.cusName;
|
|
|
+ form.value.delegateInfo.cusCode = form.value?.delegate.cusCode;
|
|
|
+ } else {
|
|
|
+ form.value.delegateInfo = null as any;
|
|
|
+ form.value.delegate = null as any;
|
|
|
+ }
|
|
|
|
|
|
- const params = {
|
|
|
- ...form.value,
|
|
|
- ...form.value.queryType6,
|
|
|
- ...form.value.inoculation,
|
|
|
- animalIds: animalIds.value,
|
|
|
- };
|
|
|
- console.log('提交参数:', params);
|
|
|
- let res = null;
|
|
|
- if (isEdit.value) {
|
|
|
- res = await useClientRequest.post('/plt-api/app/plantationTask/updateTask', params);
|
|
|
- } else {
|
|
|
- res = await useClientRequest.post('/plt-api/app/plantationTask/saveTask', params);
|
|
|
- }
|
|
|
+ const params = {
|
|
|
+ ...form.value,
|
|
|
+ ...form.value.queryType6,
|
|
|
+ ...form.value.inoculation,
|
|
|
+ animalIds: animalIds.value,
|
|
|
+ };
|
|
|
+ console.log('提交参数:', params);
|
|
|
+ let res = null;
|
|
|
+ if (isEdit.value) {
|
|
|
+ res = await useClientRequest.post('/plt-api/app/plantationTask/updateTask', params);
|
|
|
+ } else {
|
|
|
+ res = await useClientRequest.post('/plt-api/app/plantationTask/saveTask', params);
|
|
|
+ }
|
|
|
|
|
|
- if (res.code == 200) {
|
|
|
- uni.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- uni.$emit('refreshportList');
|
|
|
- setTimeout(() => {
|
|
|
- uni.navigateBack();
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
- } catch (error: any) {
|
|
|
- // 滚动到第一个错误字段
|
|
|
- console.log(error);
|
|
|
+ if (res.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ uni.$emit('refreshportList');
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ // 滚动到第一个错误字段
|
|
|
+ console.log(error);
|
|
|
|
|
|
- const firstErrorField = error && error[0].field + 'pppp';
|
|
|
- paging.value?.scrollIntoViewById(firstErrorField, 30, true);
|
|
|
- return;
|
|
|
- }
|
|
|
- }, 500, true);
|
|
|
+ const firstErrorField = error && error[0].field + 'pppp';
|
|
|
+ paging.value?.scrollIntoViewById(firstErrorField, 30, true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 500,
|
|
|
+ true,
|
|
|
+ );
|
|
|
};
|
|
|
// 暂存
|
|
|
const saveDraft = () => {
|
|
|
- uni.$u.debounce(async () => {
|
|
|
- try {
|
|
|
- const params = {
|
|
|
- ...form.value,
|
|
|
- ...form.value.queryType6,
|
|
|
- animalIds: animalIds.value,
|
|
|
- };
|
|
|
- if (form.value?.delegate?.cusCode) {
|
|
|
- form.value.delegateInfo.cusName = form.value?.delegate?.cusName;
|
|
|
- form.value.delegateInfo.cusCode = form.value?.delegate?.cusCode;
|
|
|
- }
|
|
|
- console.log('暂存参数:', params);
|
|
|
- const res = await useClientRequest.post('/plt-api/app/plantationTask/draftTask', params);
|
|
|
- if (res.code == 200) {
|
|
|
- uni.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- uni.navigateBack();
|
|
|
- }, 1000);
|
|
|
+ uni.$u.debounce(
|
|
|
+ async () => {
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ ...form.value,
|
|
|
+ ...form.value.queryType6,
|
|
|
+ animalIds: animalIds.value,
|
|
|
+ };
|
|
|
+ if (form.value?.delegate?.cusCode) {
|
|
|
+ form.value.delegateInfo.cusName = form.value?.delegate?.cusName;
|
|
|
+ form.value.delegateInfo.cusCode = form.value?.delegate?.cusCode;
|
|
|
+ }
|
|
|
+ console.log('暂存参数:', params);
|
|
|
+ const res = await useClientRequest.post('/plt-api/app/plantationTask/draftTask', params);
|
|
|
+ if (res.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ console.log(error, 'error');
|
|
|
}
|
|
|
- } catch (error: any) {
|
|
|
- console.log(error, 'error');
|
|
|
- }
|
|
|
- }, 500, true);
|
|
|
+ },
|
|
|
+ 500,
|
|
|
+ true,
|
|
|
+ );
|
|
|
};
|
|
|
const clickSwipe = async (name: any, index: number) => {
|
|
|
if (name?.index == 0) {
|
|
|
@@ -1339,13 +1408,28 @@ function handleLaboratoryClose() {
|
|
|
}
|
|
|
// 处理实验室的打开
|
|
|
function openLaboratory() {
|
|
|
- uni.$on('cultivationLocationSelected', function (data) {
|
|
|
- console.log(data);
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/tools/select-cultivation-location/index`,
|
|
|
+ success: (res) => {
|
|
|
+ if (form.value?.landLayers) {
|
|
|
+ res.eventChannel.emit('selectCultivationLocation', {
|
|
|
+ baseid: form.value.baseId,
|
|
|
+ list: form.value?.landLayers,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let list = [];
|
|
|
+ form.value.landIds?.forEach((i) => {
|
|
|
+ list.push({
|
|
|
+ id: i.id,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ res.eventChannel.emit('selectCultivationLocation', {
|
|
|
+ baseid: form.value.baseId,
|
|
|
+ list: list,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
});
|
|
|
- uni.$u.route({
|
|
|
- type: 'navigateTo',
|
|
|
- url: '/tools/select-cultivation-location/index',
|
|
|
- })
|
|
|
}
|
|
|
// 处理抽屉确认事件
|
|
|
function handleLaboratoryConfirm(data: any) {
|