hookehuyr

购物车相关页面进行删除操作后逻辑优化调整

1 <!-- 1 <!--
2 * @Date: 2024-07-23 16:24:08 2 * @Date: 2024-07-23 16:24:08
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-07-26 16:37:21 4 + * @LastEditTime: 2024-07-26 17:03:12
5 * @FilePath: /temple_material_request/src/components/chooseMaterial/index.vue 5 * @FilePath: /temple_material_request/src/components/chooseMaterial/index.vue
6 * @Description: 选择物资组件 6 * @Description: 选择物资组件
7 --> 7 -->
...@@ -174,6 +174,10 @@ const onLoad = async () => { ...@@ -174,6 +174,10 @@ const onLoad = async () => {
174 // 加载状态结束 174 // 加载状态结束
175 finished.value = true; 175 finished.value = true;
176 } 176 }
177 + // 如果查询到的数据大于0,需要取消全选
178 + if (data.length) {
179 + is_all_checked.value = false;
180 + }
177 } 181 }
178 }; 182 };
179 183
...@@ -265,6 +269,10 @@ const addShoppingCart = async () => { // 新增购物车 ...@@ -265,6 +269,10 @@ const addShoppingCart = async () => { // 新增购物车
265 // 过滤 arr1,排除 id 在 idsToRemove 中的元素 269 // 过滤 arr1,排除 id 在 idsToRemove 中的元素
266 list.value = list.value.filter(item => !idsToRemove.includes(item.id)); 270 list.value = list.value.filter(item => !idsToRemove.includes(item.id));
267 271
272 + if (!list.value.length) {
273 + is_all_checked.value = false;
274 + }
275 +
268 // 购物车数量 276 // 购物车数量
269 getCartCount(); 277 getCartCount();
270 278
......
1 <!-- 1 <!--
2 * @Date: 2024-07-23 10:50:38 2 * @Date: 2024-07-23 10:50:38
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-07-26 16:25:16 4 + * @LastEditTime: 2024-07-26 17:17:26
5 * @FilePath: /temple_material_request/src/views/material_list.vue 5 * @FilePath: /temple_material_request/src/views/material_list.vue
6 * @Description: 物资情况页面 6 * @Description: 物资情况页面
7 --> 7 -->
...@@ -77,13 +77,23 @@ onMounted(async () => { ...@@ -77,13 +77,23 @@ onMounted(async () => {
77 if (tabList.value.length) { // 默认选中组别ID 77 if (tabList.value.length) { // 默认选中组别ID
78 dept_id.value = tabList.value[0]['dept_id']; 78 dept_id.value = tabList.value[0]['dept_id'];
79 } else { // 组别为空时跳转到购物车页面 79 } else { // 组别为空时跳转到购物车页面
80 - showDialog({ 80 + // showDialog({
81 - title: '温馨提示', 81 + // title: '温馨提示',
82 - message: '物资列表为空,将前往添加!', 82 + // message: '物资列表为空,将前往添加!',
83 - confirmButtonColor: styleColor.baseColor 83 + // confirmButtonColor: styleColor.baseColor
84 - }).then(() => { 84 + // }).then(() => {
85 - // 跳转购物车页面 85 + // // 跳转购物车页面
86 - $router.push({ 86 + // $router.push({
87 + // path: '/material_pre_request',
88 + // query: {
89 + // activity_id,
90 + // form_id,
91 + // client_id
92 + // }
93 + // })
94 + // });
95 + // 跳转购物车页面
96 + $router.push({
87 path: '/material_pre_request', 97 path: '/material_pre_request',
88 query: { 98 query: {
89 activity_id, 99 activity_id,
...@@ -91,7 +101,6 @@ onMounted(async () => { ...@@ -91,7 +101,6 @@ onMounted(async () => {
91 client_id 101 client_id
92 } 102 }
93 }) 103 })
94 - });
95 } 104 }
96 } 105 }
97 }); 106 });
......
1 <!-- 1 <!--
2 * @Date: 2024-07-23 12:53:15 2 * @Date: 2024-07-23 12:53:15
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-07-26 14:47:28 4 + * @LastEditTime: 2024-07-26 17:22:46
5 * @FilePath: /temple_material_request/src/views/material_pre_request.vue 5 * @FilePath: /temple_material_request/src/views/material_pre_request.vue
6 * @Description: 待申领物资页面 6 * @Description: 待申领物资页面
7 --> 7 -->
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 </van-row> 28 </van-row>
29 </van-sticky> 29 </van-sticky>
30 <div v-for="item in list" :id="item.good_id" :key="item" class="list-boxer"> 30 <div v-for="item in list" :id="item.good_id" :key="item" class="list-boxer">
31 - <van-row align="center" justify="space-between"> 31 + <van-row gutter="10" align="center" justify="space-between">
32 <van-col span="16" style="display: flex;"> 32 <van-col span="16" style="display: flex;">
33 <span v-if="item.edit"> 33 <span v-if="item.edit">
34 <van-icon v-if="item.checked" @click="onCheck(item)" name="checked" size="1.25rem" :color="styleColor.baseColor" /> 34 <van-icon v-if="item.checked" @click="onCheck(item)" name="checked" size="1.25rem" :color="styleColor.baseColor" />
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
56 </van-row> 56 </van-row>
57 <div v-if="item.error" style="padding: 0.5rem 2rem 0 0; font-size: 0.85rem; color: red; text-align: right;">输入值有误</div> 57 <div v-if="item.error" style="padding: 0.5rem 2rem 0 0; font-size: 0.85rem; color: red; text-align: right;">输入值有误</div>
58 </div> 58 </div>
59 + <van-empty v-if="!list.length" image="error" description="待申领物资为空" />
59 <div style="height: 10rem;"></div> 60 <div style="height: 10rem;"></div>
60 <div style="position: fixed; left: 0; right: 0; bottom:4.5rem; padding: 1rem;"> 61 <div style="position: fixed; left: 0; right: 0; bottom:4.5rem; padding: 1rem;">
61 <van-button icon="plus" type="primary" :color="styleColor.baseColor" plain block :disabled="disabled_btn" @click="addMore">添加更多</van-button> 62 <van-button icon="plus" type="primary" :color="styleColor.baseColor" plain block :disabled="disabled_btn" @click="addMore">添加更多</van-button>
...@@ -125,7 +126,7 @@ ...@@ -125,7 +126,7 @@
125 <script setup> 126 <script setup>
126 import { ref } from 'vue' 127 import { ref } from 'vue'
127 import { useRoute, useRouter } from 'vue-router' 128 import { useRoute, useRouter } from 'vue-router'
128 -import { showToast, showConfirmDialog } from 'vant'; 129 +import { showToast, showConfirmDialog, showDialog } from 'vant';
129 import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js' 130 import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
130 //import { } from '@/utils/generateModules.js' 131 //import { } from '@/utils/generateModules.js'
131 //import { } from '@/utils/generateIcons.js' 132 //import { } from '@/utils/generateIcons.js'
...@@ -183,7 +184,14 @@ const getCartList = async () => { ...@@ -183,7 +184,14 @@ const getCartList = async () => {
183 item.checked = false; 184 item.checked = false;
184 }) 185 })
185 if (!list.value.length) { // 购物车为空 186 if (!list.value.length) { // 购物车为空
186 - addMore(); 187 + // showDialog({
188 + // title: '温馨提示',
189 + // message: '物资列表为空,将前往添加!',
190 + // confirmButtonColor: styleColor.baseColor
191 + // }).then(() => {
192 + // show_choose_material.value = true;
193 + // });
194 + sum_num.value = list.value.length; // 品项数量
187 } else { 195 } else {
188 sum_num.value = list.value.length; // 品项数量 196 sum_num.value = list.value.length; // 品项数量
189 } 197 }
...@@ -356,7 +364,13 @@ const onConfirmRequest = () => { // 确定申领回调 ...@@ -356,7 +364,13 @@ const onConfirmRequest = () => { // 确定申领回调
356 showToast('请选择使用日期'); 364 showToast('请选择使用日期');
357 return; 365 return;
358 } 366 }
359 - showType.value = true; 367 + let sum = list.value.some((item) => { return +item.apply_number > 0 }); // 判断是否有一个值不等于0
368 + if (!sum) {
369 + showToast('物资数量都没有填写');
370 + return;
371 + } else {
372 + showType.value = true;
373 + }
360 } 374 }
361 375
362 const scrollToSection = (id) => { // 滚动到指定位置 376 const scrollToSection = (id) => { // 滚动到指定位置
...@@ -426,9 +440,10 @@ const onCloseDetail = () => { // 关闭物资详情窗口 ...@@ -426,9 +440,10 @@ const onCloseDetail = () => { // 关闭物资详情窗口
426 .select-all-item { 440 .select-all-item {
427 padding: 0.5rem 1rem; 441 padding: 0.5rem 1rem;
428 background-color: white; 442 background-color: white;
443 + border-bottom: 1px solid #f0f0f0;
429 } 444 }
430 .list-boxer { 445 .list-boxer {
431 - margin: 0; padding: 1rem; border-top: 1px solid #f0f0f0; 446 + margin: 0; padding: 1rem;
432 } 447 }
433 } 448 }
434 449
......
1 <!-- 1 <!--
2 * @Date: 2024-07-23 12:53:15 2 * @Date: 2024-07-23 12:53:15
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-07-26 14:42:54 4 + * @LastEditTime: 2024-07-26 16:44:38
5 * @FilePath: /temple_material_request/src/views/material_request.vue 5 * @FilePath: /temple_material_request/src/views/material_request.vue
6 * @Description: 申领物资页面 6 * @Description: 申领物资页面
7 --> 7 -->
...@@ -140,7 +140,7 @@ const dept_id = ref(''); ...@@ -140,7 +140,7 @@ const dept_id = ref('');
140 const is_all_checked = ref(false); 140 const is_all_checked = ref(false);
141 const num_value = ref(''); 141 const num_value = ref('');
142 142
143 -const onCheckAll = () => { 143 +const onCheckAll = () => { // 全选操作
144 is_all_checked.value = !is_all_checked.value; 144 is_all_checked.value = !is_all_checked.value;
145 if (is_all_checked.value) { 145 if (is_all_checked.value) {
146 list.value.forEach(item => { 146 list.value.forEach(item => {
...@@ -154,7 +154,7 @@ const onCheckAll = () => { ...@@ -154,7 +154,7 @@ const onCheckAll = () => {
154 } 154 }
155 } 155 }
156 156
157 -const onCheck = (item) => { 157 +const onCheck = (item) => { // 单选操作
158 item.checked = !item.checked; 158 item.checked = !item.checked;
159 // 全部为选中 159 // 全部为选中
160 let all_checked = list.value.every((item) => item.checked === true); 160 let all_checked = list.value.every((item) => item.checked === true);
...@@ -170,8 +170,8 @@ const onCheck = (item) => { ...@@ -170,8 +170,8 @@ const onCheck = (item) => {
170 } 170 }
171 171
172 const onBlur = (item) => { // 输入框失去焦点回调 172 const onBlur = (item) => { // 输入框失去焦点回调
173 - console.warn(item);
174 if (item.checked) { 173 if (item.checked) {
174 + // 错误提示
175 if (item.total_apply_number === null || item.total_apply_number === '') { 175 if (item.total_apply_number === null || item.total_apply_number === '') {
176 item.error = true; 176 item.error = true;
177 } else { 177 } else {
...@@ -182,11 +182,11 @@ const onBlur = (item) => { // 输入框失去焦点回调 ...@@ -182,11 +182,11 @@ const onBlur = (item) => { // 输入框失去焦点回调
182 182
183 const active = ref(0); 183 const active = ref(0);
184 const onChange = (index) => { // 切换标签回调 184 const onChange = (index) => { // 切换标签回调
185 - console.warn(index);
186 // 取消全选 185 // 取消全选
187 is_all_checked.value = false; 186 is_all_checked.value = false;
188 // 187 //
189 dept_id.value = tabList.value[index]['dept_id']; 188 dept_id.value = tabList.value[index]['dept_id'];
189 + // 重置查询条件
190 limit.value = 20; 190 limit.value = 20;
191 offset.value = 0; 191 offset.value = 0;
192 loading.value = false; 192 loading.value = false;
...@@ -197,7 +197,6 @@ const onChange = (index) => { // 切换标签回调 ...@@ -197,7 +197,6 @@ const onChange = (index) => { // 切换标签回调
197 const list = ref([]); 197 const list = ref([]);
198 const loading = ref(false); 198 const loading = ref(false);
199 const finished = ref(false); 199 const finished = ref(false);
200 -
201 const limit = ref(20); 200 const limit = ref(20);
202 const offset = ref(0); 201 const offset = ref(0);
203 202
...@@ -205,10 +204,12 @@ const onLoad = async () => { ...@@ -205,10 +204,12 @@ const onLoad = async () => {
205 // 异步更新数据 204 // 异步更新数据
206 const { code, data } = await getGoodUseListAPI({ activity_id, dept_id: dept_id.value, is_previous: 1, offset: offset.value, limit: limit.value }); 205 const { code, data } = await getGoodUseListAPI({ activity_id, dept_id: dept_id.value, is_previous: 1, offset: offset.value, limit: limit.value });
207 if (code) { 206 if (code) {
207 + // 新增选中,错误字段
208 data.forEach(item => { 208 data.forEach(item => {
209 item.checked = false; 209 item.checked = false;
210 item.error = false; 210 item.error = false;
211 }); 211 });
212 + //
212 list.value = _.concat(list.value, data); 213 list.value = _.concat(list.value, data);
213 list.value = _.uniqBy(list.value, 'good_id'); 214 list.value = _.uniqBy(list.value, 'good_id');
214 offset.value = list.value.length; 215 offset.value = list.value.length;
...@@ -218,9 +219,11 @@ const onLoad = async () => { ...@@ -218,9 +219,11 @@ const onLoad = async () => {
218 // 加载状态结束 219 // 加载状态结束
219 finished.value = true; 220 finished.value = true;
220 } 221 }
222 + // 如果查询到的数据大于0,需要取消全选
223 + if (data.length) {
224 + is_all_checked.value = false;
225 + }
221 } 226 }
222 - // TODO: 如果查询到的数据大于0,需要取消全选
223 - is_all_checked.value = false;
224 }; 227 };
225 228
226 const material_id = ref(''); 229 const material_id = ref('');
......