|
|
@@ -40,7 +40,7 @@
|
|
|
|
|
|
<view v-if="showSearch" class="search-suggest">
|
|
|
<block v-if="!$util.isEmpty(searchList)">
|
|
|
- <view class="suggest-item" v-for="(item, index) in searchList" :key="index" @click="getCustom(item)">
|
|
|
+ <view class="suggest-item" v-for="(item, index) in searchList" :key="index" @click="getCustom(index)">
|
|
|
<view class="suggest-name">{{ item.name }}</view>
|
|
|
<view class="suggest-meta">
|
|
|
<text>{{ item.visitTime ? item.visitTime.substr(5, 11) : '' }}</text>
|
|
|
@@ -56,7 +56,7 @@
|
|
|
:key="index"
|
|
|
class="status-tab"
|
|
|
:class="{ active: tabIndex == index }"
|
|
|
- @click="change({ index: index, item: item })"
|
|
|
+ @click="change(index)"
|
|
|
>
|
|
|
<view class="tab-name">{{ item.name }}</view>
|
|
|
<view class="tab-value">{{ item.value }}</view>
|
|
|
@@ -66,10 +66,16 @@
|
|
|
|
|
|
<view class="list-wrap">
|
|
|
<block v-if="!$util.isEmpty(list.data)">
|
|
|
+ <!--
|
|
|
+ 使用 item.id 作为唯一 key。
|
|
|
+ 注意:在 uni-app 小程序端,:key 表达式中不能包含逻辑运算符(如 ||),
|
|
|
+ 否则在事件传参(如 @click)时,小程序编译器生成的 getExtraValue 无法解析 key,
|
|
|
+ 会导致 "Cannot read property 'orderSn||index' of undefined" 报错。
|
|
|
+ -->
|
|
|
<view
|
|
|
class="order-card"
|
|
|
v-for="(item, index) in list.data"
|
|
|
- :key="item.id || item.orderSn || index"
|
|
|
+ :key="item.id"
|
|
|
@click="$util.pageTo({ url: '/admin/order/detail', query: { id: item.id } })"
|
|
|
>
|
|
|
<view class="card-header">
|
|
|
@@ -160,7 +166,7 @@
|
|
|
<view
|
|
|
class="outline-action"
|
|
|
:class="{ disabled: !item._canSendWork }"
|
|
|
- @click.stop="item._canSendWork ? sendWork(item) : ''"
|
|
|
+ @click.stop="item._canSendWork ? sendWork(index) : ''"
|
|
|
>
|
|
|
<image
|
|
|
class="action-icon"
|
|
|
@@ -171,14 +177,14 @@
|
|
|
<text>通知制作</text>
|
|
|
</view>
|
|
|
|
|
|
- <view class="outline-action" v-if="item._showFetchAction" @click.stop="getOrderFn(item)">已取货</view>
|
|
|
- <view class="outline-action" v-if="item._showSelfDeliveryAction" @click.stop="sendOrderFn(item)">自配送</view>
|
|
|
- <view class="outline-action" v-if="item._showConfirmReachAction" @click.stop="confirmReach(item)">确认送达</view>
|
|
|
+ <view class="outline-action" v-if="item._showFetchAction" @click.stop="getOrderFn(index)">已取货</view>
|
|
|
+ <view class="outline-action" v-if="item._showSelfDeliveryAction" @click.stop="sendOrderFn(index)">自配送</view>
|
|
|
+ <view class="outline-action" v-if="item._showConfirmReachAction" @click.stop="confirmReach(index)">确认送达</view>
|
|
|
|
|
|
<view
|
|
|
class="solid-action"
|
|
|
:class="{ disabled: !item._isPaid }"
|
|
|
- @click.stop="item._isPaid ? printOrder(item) : ''"
|
|
|
+ @click.stop="item._isPaid ? printOrder(index) : ''"
|
|
|
>
|
|
|
<image
|
|
|
class="action-icon action-icon-white"
|
|
|
@@ -215,7 +221,7 @@
|
|
|
|
|
|
<uni-popup ref="getStaffRef" background-color="#fff" type="center" :animation="false">
|
|
|
<view class="staff-popup">
|
|
|
- <text class="staff-item" v-for="(item, index) in staffList" :key="index" @click="getCurrentStaff(item.id)">
|
|
|
+ <text class="staff-item" v-for="(item, index) in staffList" :key="index" @click="getCurrentStaff(index)">
|
|
|
{{ item.name }}
|
|
|
</text>
|
|
|
</view>
|
|
|
@@ -427,7 +433,13 @@ export default {
|
|
|
this.resetList();
|
|
|
this.getOrderList();
|
|
|
},
|
|
|
- getCustom (item) {
|
|
|
+ /**
|
|
|
+ * 选择搜索建议的客户
|
|
|
+ * @param {number} index - 搜索结果列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ getCustom (index) {
|
|
|
+ const item = this.searchList[index];
|
|
|
+ if (!item) return;
|
|
|
this.showSearch = false;
|
|
|
this.customId = item.id;
|
|
|
this.searchText = item.name || this.searchText;
|
|
|
@@ -475,7 +487,13 @@ export default {
|
|
|
this.getOrderList();
|
|
|
}
|
|
|
},
|
|
|
- sendWork (item) {
|
|
|
+ /**
|
|
|
+ * 通知制作
|
|
|
+ * @param {number} index - 订单列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ sendWork (index) {
|
|
|
+ const item = this.list.data[index];
|
|
|
+ if (!item) return;
|
|
|
this.$util.confirmModal({ content: "确认通知制作?" }, () => {
|
|
|
needWork({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
@@ -486,7 +504,13 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- getOrderFn (item) {
|
|
|
+ /**
|
|
|
+ * 确认取货
|
|
|
+ * @param {number} index - 订单列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ getOrderFn (index) {
|
|
|
+ const item = this.list.data[index];
|
|
|
+ if (!item) return;
|
|
|
this.$util.confirmModal({ content: "确认取货?" }, () => {
|
|
|
fetchOrder({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
@@ -497,7 +521,13 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- confirmReach (item) {
|
|
|
+ /**
|
|
|
+ * 确认送达
|
|
|
+ * @param {number} index - 订单列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ confirmReach (index) {
|
|
|
+ const item = this.list.data[index];
|
|
|
+ if (!item) return;
|
|
|
this.$util.confirmModal({ content: "确认送达?" }, () => {
|
|
|
sendReach({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
@@ -508,7 +538,13 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- sendOrderFn (item) {
|
|
|
+ /**
|
|
|
+ * 自配送
|
|
|
+ * @param {number} index - 订单列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ sendOrderFn (index) {
|
|
|
+ const item = this.list.data[index];
|
|
|
+ if (!item) return;
|
|
|
this.$util.confirmModal({ content: "确认自配送?" }, () => {
|
|
|
sendOrder({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
@@ -528,9 +564,15 @@ export default {
|
|
|
this.resetList();
|
|
|
this.getOrderList();
|
|
|
},
|
|
|
- getCurrentStaff (id) {
|
|
|
+ /**
|
|
|
+ * 选择下单人(员工)
|
|
|
+ * @param {number} index - 员工列表中的索引。传递索引而非 item.id,是为了保持传参风格一致,并完美兼容小程序。
|
|
|
+ */
|
|
|
+ getCurrentStaff (index) {
|
|
|
+ const item = this.staffList[index];
|
|
|
+ if (!item) return;
|
|
|
this.resetList();
|
|
|
- this.shopAdminId = id;
|
|
|
+ this.shopAdminId = item.id;
|
|
|
this.$refs.getStaffRef.close();
|
|
|
this.getOrderList();
|
|
|
},
|
|
|
@@ -552,7 +594,13 @@ export default {
|
|
|
}
|
|
|
this.getOrderList();
|
|
|
},
|
|
|
- printOrder (item) {
|
|
|
+ /**
|
|
|
+ * 打印订单
|
|
|
+ * @param {number} index - 订单列表中的索引。传递索引而非 item 对象,是为了避免微信小程序端在 v-for 循环中直接传递对象导致 getExtraValue 报错。
|
|
|
+ */
|
|
|
+ printOrder (index) {
|
|
|
+ const item = this.list.data[index];
|
|
|
+ if (!item) return;
|
|
|
onlinePrintOrder({ id: item.id }).then(res => {
|
|
|
if (res.code == 1) {
|
|
|
this.$msg("操作成功");
|
|
|
@@ -590,11 +638,15 @@ export default {
|
|
|
];
|
|
|
});
|
|
|
},
|
|
|
- change (e) {
|
|
|
- if (this.tabIndex == e.index) {
|
|
|
+ /**
|
|
|
+ * 切换订单状态 Tab
|
|
|
+ * @param {number} index - 选中的 Tab 索引。
|
|
|
+ */
|
|
|
+ change (index) {
|
|
|
+ if (this.tabIndex == index) {
|
|
|
return false;
|
|
|
}
|
|
|
- this.tabIndex = e.index;
|
|
|
+ this.tabIndex = index;
|
|
|
this.resetList();
|
|
|
this.getOrderList();
|
|
|
},
|