1. 优化了一些交互,中药药品编辑交互

2. dev和生产环境统一鉴别
This commit is contained in:
李琦
2026-05-30 13:52:44 +08:00
parent ad370375a7
commit 6d93314222
15 changed files with 496 additions and 326 deletions

View File

@@ -49,6 +49,7 @@
logout,
toUpload,
} from '@/api/all.js'
import { chooseAvatarImage } from '@/common/js/select-avatar-image.js';
export default {
data() {
return {
@@ -85,56 +86,24 @@
}
},
selectAct() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: (res) => {
uni.showLoading({
title: '请稍后...'
})
const tempFiles = res.tempFiles;
let resSize = tempFiles[0].size;
// 1M=1024KB=1048576B
console.log(resSize)
if (resSize > 1048576) {
uni.showToast({
title: "上传图片大小不能超过1MB",
icon: 'error'
chooseAvatarImage({
formData: {
store_id: uni.getStorageSync('store_id') || '11001',
},
onSuccess: (res) => {
const req = this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
if (req.errcode == 0) {
toUpload({
store_id: uni.getStorageSync('store_id') || '11001',
avatar: req.data.url,
}).then(() => {
this.getDoctor();
this.$toast('编辑成功');
});
return
} else {
this.$toast(res.msg);
}
uni.uploadFile({
url: 'https://api.xiaokang88.com/open-api/upload/old-admin-img',
filePath: res.tempFiles[0]['path'],
name: 'file',
header: {
authorization: `Bearer ${uni.getStorageSync('token')}`
},
formData: {
store_id: uni.getStorageSync('store_id') || '11001'
},
success: res => {
let req = this.$u.test.jsonString(res.data) ? JSON.parse(res
.data) : res.data
// console.log(req, 'req')
if (req.errcode == 0) {
toUpload({
store_id: uni.getStorageSync('store_id') ||
'11001',
avatar: req.data.url
}).then((res) => {
this.getDoctor()
this.$toast('编辑成功');
})
uni.hideLoading()
} else {
this.$toast(res.msg);
}
}
});
}
},
});
},
logout() {

View File

@@ -154,7 +154,7 @@
<view v-if="parsedObj.question" class="text-block">
<text class="block-content">{{ parsedObj.question }}</text>
</view>
<view v-for="(row, idx) in (parsedObj.drugs || [])" :key="'fd-' + idx" class="info-row">
<view v-for="row in followUpDrugs" :key="row._wxKey" class="info-row">
<text class="label">{{ row.name || '药品' }}</text>
<text class="value">×{{ row.quantity != null ? row.quantity : 1 }}</text>
</view>
@@ -290,7 +290,7 @@
</view>
<view v-if="parsedObj.questions && parsedObj.questions.length" class="transfer-qa">
<text class="transfer-qa-title">咨询问题</text>
<view v-for="(qa, qix) in parsedObj.questions" :key="qix" class="transfer-qa-item">
<view v-for="(qa, qix) in transferQuestionsWithKey" :key="qa._wxKey" class="transfer-qa-item">
<text class="transfer-qa-q">{{ qix + 1 }}. {{ qa.question }}</text>
<text class="transfer-qa-a">{{ qa.answer }}</text>
</view>
@@ -318,6 +318,7 @@
<script>
import { parseMessageContent } from '../utils/messageParse.js';
import { withWxKey } from '@/utils/wxListKey.js';
export default {
name: 'MessageBubble',
@@ -388,6 +389,14 @@ export default {
if (st === 'no' || st === '0') return '否,未使用过';
return '';
},
followUpDrugs() {
const drugs = (this.parsedObj && this.parsedObj.drugs) || [];
return withWxKey(drugs, 'id', 'fd');
},
transferQuestionsWithKey() {
const qs = (this.parsedObj && this.parsedObj.questions) || [];
return withWxKey(qs, 'id', 'tq');
},
experienceRxPayload() {
const pc = this.parsedObj;
if (!pc || this.msg.message_type !== 11) return {};

View File

@@ -44,7 +44,7 @@
<text class="spinner-text">历史记录加载中...</text>
</view>
<view v-for="(msg, index) in messages" :key="msg.id || 'm-' + index" class="message-wrapper">
<view v-for="(msg, index) in messages" :key="msg._wxKey" class="message-wrapper">
<view v-if="shouldShowTime(msg, index)" class="time-divider">
<text class="time-text">{{ timeDividerText(msg) }}</text>
</view>
@@ -167,7 +167,7 @@
<view class="tool-cell-icon"><u-icon name="close-circle" size="30" color="#6ACDBB"></u-icon></view>
<text class="tool-cell-label">拒诊</text>
</view>
<view v-for="n in 7" :key="'tool-ph-' + n" class="tool-cell tool-cell--placeholder"></view>
<view v-for="ph in toolPlaceholderCells" :key="ph._wxKey" class="tool-cell tool-cell--placeholder"></view>
</view>
</swiper-item>
</swiper>
@@ -182,8 +182,8 @@
</view>
<scroll-view v-if="!quickReplyLoading && quickReplyList.length" class="quick-reply-scroll" scroll-y>
<view
v-for="(item, idx) in quickReplyList"
:key="idx"
v-for="item in quickReplyList"
:key="item._wxKey"
class="quick-reply-row"
@click="selectQuickReply(item)"
>
@@ -222,8 +222,8 @@
<text class="orders-v">{{ registerOrderStatusText(registerOrderBlock.status) }}</text>
</view>
<view
v-for="(sub, six) in childOrdersBlock"
:key="'osub-' + six"
v-for="sub in childOrdersWithKey"
:key="sub._wxKey"
class="orders-sub"
>
<text class="orders-sub-label">子订单</text>
@@ -235,10 +235,11 @@
<view v-if="ordersRxLoading" class="orders-hint">加载中</view>
<view v-else-if="!ordersRxList.length" class="orders-hint">暂无处方</view>
<view
v-for="(rx, orix) in ordersRxList"
:key="'orx-' + orix"
v-for="rx in ordersRxList"
:key="rx._wxKey"
class="orders-rx-row"
@click="onOrdersRxTap(orix)"
:data-wx-key="rx._wxKey"
@click="onOrdersRxTap"
>
<text class="orders-rx-no">{{ rx.order_no || rx.prescription_no || '处方' }}</text>
<text v-if="rx.total_pay_price != null" class="orders-rx-price">¥{{ rx.total_pay_price }}</text>
@@ -277,7 +278,7 @@
</view>
<view v-if="transferCard.questions && transferCard.questions.length" class="td-qa">
<text class="td-qa-title">咨询问题</text>
<view v-for="(qa, qix) in transferCard.questions" :key="'tdq-' + qix" class="td-qa-item">
<view v-for="(qa, qix) in transferQuestionsWithKey" :key="qa._wxKey" class="td-qa-item">
<text class="td-qa-q">{{ qix + 1 }}. {{ qa.question }}</text>
<text class="td-qa-a">{{ qa.answer }}</text>
</view>
@@ -326,9 +327,13 @@ import PatientDetailPanel from '../components/PatientDetailPanel.vue';
import MessageBubble from '../components/MessageBubble.vue';
import ReceptionActionBar from '../components/ReceptionActionBar.vue';
import RefuseReceptionModal from '../components/RefuseReceptionModal.vue';
import { withWxKey, ensureWxKey } from '@/utils/wxListKey.js';
import { prepareImagePath } from '@/common/js/image-compress.js';
const PENDING_RX_FROM_CHAT = 'xk_pending_rx_from_chat';
const TOOL_PLACEHOLDER_CELLS = Array.from({ length: 7 }, (_, i) => ({ _wxKey: `ph${i}` }));
export default {
components: { PatientDetailPanel, MessageBubble, ReceptionActionBar, RefuseReceptionModal },
data() {
@@ -370,7 +375,8 @@ export default {
ordersPopupOpen: false,
ordersRxList: [],
ordersRxLoading: false,
toolPanelSwiperCurrent: 0
toolPanelSwiperCurrent: 0,
toolPlaceholderCells: TOOL_PLACEHOLDER_CELLS
};
},
computed: {
@@ -427,6 +433,13 @@ export default {
const raw = ro.child_orders || ro.sub_orders || ro.orders;
return Array.isArray(raw) ? raw : [];
},
childOrdersWithKey() {
return withWxKey(this.childOrdersBlock, 'id', 'osub');
},
transferQuestionsWithKey() {
const qs = (this.transferCard && this.transferCard.questions) || [];
return withWxKey(qs, 'id', 'tdq');
},
refuseToolDisabled() {
return Number(this.patientInfo && this.patientInfo.status) !== 1;
},
@@ -586,9 +599,13 @@ export default {
this.transferCard = null;
}
},
syncMessagesFromRoom() {
const raw = chatRoomManager.getRoomMessages(this.roomId) || [];
this.messages = withWxKey(raw, 'id', 'm');
},
onMessageUpdated({ roomId }) {
if (roomId === this.roomId) {
this.messages = [...(chatRoomManager.getRoomMessages(this.roomId) || [])];
this.syncMessagesFromRoom();
this.$forceUpdate();
}
},
@@ -624,7 +641,7 @@ export default {
const lastMessageId = wasFirstPage ? 0 : chatRoomManager.lastMessageId;
const batch = await chatRoomManager.loadRoomMessages(this.roomId, lastMessageId);
if (batch && batch.length > 0) {
this.messages = [...(chatRoomManager.getRoomMessages(this.roomId) || [])];
this.syncMessagesFromRoom();
this.page++;
} else {
this.hasMore = false;
@@ -674,16 +691,17 @@ export default {
return Math.abs(a - b) < 60000;
});
if (tempIndex !== -1) {
this.$set(this.messages, tempIndex, { ...message, isTemporary: false });
const patched = ensureWxKey({ ...message, isTemporary: false }, 'id', `m${tempIndex}`);
this.$set(this.messages, tempIndex, patched);
return;
}
}
const existingIndex = this.messages.findIndex((m) => m.id === message.id);
if (existingIndex !== -1) {
this.$set(this.messages, existingIndex, message);
this.$set(this.messages, existingIndex, ensureWxKey(message, 'id', `m${existingIndex}`));
return;
}
this.messages.push(message);
this.messages.push(ensureWxKey(message, 'id', `m${this.messages.length}`));
if (message.message_type === chatConfig.messageTypes['end-consultation']) {
this.isConsultationEnded = true;
}
@@ -817,7 +835,7 @@ export default {
page_size: 30
});
const payload = this.unwrap(res) || {};
this.ordersRxList = Array.isArray(payload.list) ? payload.list : [];
this.ordersRxList = withWxKey(Array.isArray(payload.list) ? payload.list : [], 'id', 'orx');
} catch (e) {
console.warn(e);
this.ordersRxList = [];
@@ -830,8 +848,9 @@ export default {
const n = Number(status);
return map[n] != null ? map[n] : String(status);
},
onOrdersRxTap(index) {
const rx = this.ordersRxList[index];
onOrdersRxTap(e) {
const wxKey = e && e.currentTarget && e.currentTarget.dataset && e.currentTarget.dataset.wxKey;
const rx = this.ordersRxList.find((r) => r._wxKey === wxKey);
const id = rx && (rx.id || rx.prescription_id);
if (!id) return;
let url = `/pages/my/prescriptionDetail?id=${id}`;
@@ -967,7 +986,7 @@ export default {
const res = await getQuickReplyListApi();
const raw = this.unwrap(res);
const list = Array.isArray(raw) ? raw : raw && Array.isArray(raw.list) ? raw.list : [];
this.quickReplyList = list;
this.quickReplyList = withWxKey(list, 'id', 'qr');
} catch (e) {
console.error(e);
uni.showToast({ title: '加载常用回复失败', icon: 'none' });
@@ -1042,6 +1061,7 @@ export default {
const idx = this.messages.findIndex((m) => m.id === tempId);
if (idx !== -1) {
this.$set(this.messages[idx], 'id', mid);
this.$set(this.messages[idx], '_wxKey', String(mid));
this.$set(this.messages[idx], 'isTemporary', false);
}
}
@@ -1056,9 +1076,33 @@ export default {
if (this.inputLocked) return;
uni.chooseImage({
count: 1,
success: (res) => {
this.uploadMedia(res.tempFilePaths[0], 'image');
}
success: async (res) => {
const tempFile = res.tempFiles && res.tempFiles[0];
const filePath = tempFile ? tempFile.path : res.tempFilePaths[0];
let fileSize = tempFile ? tempFile.size : 0;
if (!fileSize && filePath) {
try {
const info = await new Promise((resolve, reject) => {
uni.getFileInfo({
filePath,
success: resolve,
fail: reject,
});
});
fileSize = info.size;
} catch (error) {
console.error(error);
}
}
const prepared = await prepareImagePath({
path: filePath,
size: fileSize,
});
if (!prepared) return;
this.uploadMedia(prepared.path, 'image');
},
});
},
async uploadMedia(filePath, kind) {

View File

@@ -28,7 +28,7 @@
<view v-if="patientList.length" class="list">
<view
v-for="(row, idx) in patientList"
:key="rowKey(row, idx)"
:key="row._wxKey"
class="ol-card flex-row flex-ali-center"
:data-idx="idx"
@tap="onPatientCardTap"
@@ -38,7 +38,6 @@
<u-loading slot="loading"></u-loading>
</u-image>
<u-badge
:key="'ol-ub-' + rowKey(row, idx) + '-' + Number(row.unread_count || 0)"
v-if="Number(row.unread_count) > 0"
:count="Number(row.unread_count)"
:offset="[-4, -4]"
@@ -174,7 +173,7 @@ export default {
}
const next = [...this.patientList];
next.splice(idx, 1, copy);
this.patientList = this.sortPatientList(next);
this.patientList = this.mapPatientRows(this.sortPatientList(next));
},
unwrap(res) {
if (res == null) return null;
@@ -182,11 +181,17 @@ export default {
if (res.data && res.data.result !== undefined) return res.data.result;
return res;
},
rowKey(row, idx) {
const room = row.room_id != null && row.room_id !== '' ? String(row.room_id) : 'r0';
const reg = row.register_id != null ? row.register_id : row.id;
const ord = row.order_no != null && row.order_no !== '' ? String(row.order_no) : '';
return `${room}-${reg != null ? reg : 'x'}-${ord}-${idx}`;
mapPatientRows(rows) {
return (rows || []).map((row, idx) => {
const room = row.room_id != null && row.room_id !== '' ? String(row.room_id) : 'r0';
const reg = row.register_id != null ? row.register_id : row.id;
const ord = row.order_no != null && row.order_no !== '' ? String(row.order_no) : '';
const ub = Number(row.unread_count || 0);
return {
...row,
_wxKey: `${room}-${reg != null ? reg : 'x'}-${ord}-${ub}`,
};
});
},
lastMessageSortTs(row) {
const t = row.last_message_time || row.updated_at || row.register_time;
@@ -276,7 +281,7 @@ export default {
const res = await getOnlineConsultationPatientListApi({ type: this.listType });
const raw = this.unwrap(res);
const arr = Array.isArray(raw) ? raw : [];
this.patientList = this.sortPatientList(arr);
this.patientList = this.mapPatientRows(this.sortPatientList(arr));
} catch (e) {
console.error(e);
this.patientList = [];

View File

@@ -135,13 +135,15 @@
</block>
<block v-if="lists.prescription_type==2">
<view class="item" v-for="(it,index) in infoList.repice" :key="item.id">
<block v-if="lists.prescription_type==2||lists.prescription_type==5||lists.prescription_type==7">
<view class="item" v-for="(it,index) in infoList.repice" :key="it.id || index">
<!-- v-for="(it,index) in item.content" :key="it.id" -->
<view class="name" style="justify-content: space-between;">
<view class="yp_name">
<text>{{ it.content.drug_name}} </text>
<text style="font-size: 24rpx;margin-left: 10rpx;">{{ it.content.specification }}</text>
<text>{{ (it.content && it.content.drug_name) || '' }} </text>
<text
v-if="it.content && it.content.specification"
class="drug-spec">{{ it.content.specification }}</text>
</view>
<text>x{{ it.number}}</text>
</view>
@@ -347,6 +349,25 @@
})
return num
},
normalizeRepice(list) {
return (list || []).map((it) => {
let content = it.content
if (typeof content === 'string') {
try {
content = JSON.parse(content || '{}')
} catch (e) {
content = {}
}
}
if (!content || typeof content !== 'object' || Array.isArray(content)) {
content = Array.isArray(content) ? content : {}
}
return {
...it,
content,
}
})
},
getInfo() {
prescripRecordDetail({
store_id: uni.getStorageSync('store_id') || '11001',
@@ -355,12 +376,9 @@
// console.log(res, 'deta');
if (res.errcode == 0) {
// this.infoList = res.data.prescript
// this.time = res.data.issue_date
// this.rpList = res.data.recipe
// this.price = res.data.total_price
this.infoList = res.data.content
const content = res.data.content
content.repice = this.normalizeRepice(content.repice)
this.infoList = content
this.rpList = res.data.pharmacistInfo
this.lists = res.data
// console.log(this.infoList, 'info');
@@ -644,6 +662,12 @@
display: flex;
justify-content: space-between;
align-items: center;
.drug-spec {
font-size: 24rpx;
color: #999;
margin-left: 10rpx;
}
}
.details {

View File

@@ -207,6 +207,7 @@
infoEdit,
toUploaded
} from "@/api/all.js";
import { chooseAvatarImage } from '@/common/js/select-avatar-image.js';
export default {
data() {
return {
@@ -377,112 +378,50 @@
},
selectActed(){
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: (res) => {
uni.showLoading({
title: '请稍后...'
})
const tempFiles = res.tempFiles;
let resSize = tempFiles[0].size;
// 1M=1024KB=1048576B
console.log(resSize)
if (resSize > 1048576) {
uni.showToast({
title: "上传图片大小不能超过1MB",
icon: 'error'
});
return
}
uni.uploadFile({
url: 'https://api.xiaokang88.com/open-api/upload/old-admin-img',
filePath: res.tempFiles[0]['path'],
name: 'file',
header: {
authorization: `Bearer ${uni.getStorageSync('token')}`
},
formData: {
store_id: uni.getStorageSync('store_id') || '11001'
},
success: res => {
let req = this.$u.test.jsonString(res.data) ? JSON.parse(res
.data) : res.data
// console.log(req, 'req')
if (req.errcode == 0) {
toUploaded({
store_id: uni.getStorageSync('store_id') ||
'11001',
avatar: req.data.url
}).then((res) => {
if (res.errcode == 0) {
this.getInfo()
this.$toast('编辑成功');
}
})
uni.hideLoading()
} else {
this.$toast(res.msg);
chooseAvatarImage({
formData: {
store_id: uni.getStorageSync('store_id') || '11001',
},
onSuccess: (res) => {
const req = this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
if (req.errcode == 0) {
toUploaded({
store_id: uni.getStorageSync('store_id') || '11001',
avatar: req.data.url,
}).then((uploadRes) => {
if (uploadRes.errcode == 0) {
this.getInfo();
this.$toast('编辑成功');
}
}
});
}
});
} else {
this.$toast(res.msg);
}
},
});
},
selectAct() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: (res) => {
uni.showLoading({
title: '请稍后...'
})
const tempFiles = res.tempFiles;
let resSize = tempFiles[0].size;
// 1M=1024KB=1048576B
console.log(resSize)
if (resSize > 1048576) {
uni.showToast({
title: "上传图片大小不能超过1MB",
icon: 'error'
});
return
}
uni.uploadFile({
url: 'https://api.xiaokang88.com/open-api/upload/old-admin-img',
filePath: res.tempFiles[0]['path'],
name: 'file',
header: {
authorization: `Bearer ${uni.getStorageSync('token')}`
},
formData: {
store_id: uni.getStorageSync('store_id') || '11001'
},
success: res => {
let req = this.$u.test.jsonString(res.data) ? JSON.parse(res
.data) : res.data
// console.log(req, 'req')
if (req.errcode == 0) {
toUpload({
store_id: uni.getStorageSync('store_id') ||
'11001',
avatar: req.data.url
}).then((res) => {
if (res.errcode == 0) {
this.getDoctor()
this.$toast('编辑成功');
}
})
uni.hideLoading()
} else {
this.$toast(res.msg);
chooseAvatarImage({
formData: {
store_id: uni.getStorageSync('store_id') || '11001',
},
onSuccess: (res) => {
const req = this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
if (req.errcode == 0) {
toUpload({
store_id: uni.getStorageSync('store_id') || '11001',
avatar: req.data.url,
}).then((uploadRes) => {
if (uploadRes.errcode == 0) {
this.getDoctor();
this.$toast('编辑成功');
}
}
});
}
});
} else {
this.$toast(res.msg);
}
},
});
},
// 保存编辑

View File

@@ -32,19 +32,19 @@
<scroll-view class="selected-strip-scroll" scroll-x enable-flex>
<view class="selected-strip-inner flex-row">
<view
v-for="(sel, six) in selectedDrugs"
:key="'sch-' + six"
v-for="sel in selectedDrugs"
:key="sel._wxKey"
class="selected-chip flex-row flex-ali-center"
>
<view
class="selected-chip-main flex-row flex-ali-center"
:data-six="six"
:data-wx-key="sel._wxKey"
@click="handleSelectedChipSearch"
>
<text class="selected-chip-name">{{ sel.drug_name || sel.name || '—' }}</text>
<text class="selected-chip-dose">{{ String(sel.number || 0) }}{{ sel.unit && sel.unit.name ? sel.unit.name : 'g' }}</text>
</view>
<view class="selected-chip-close" :data-six="six" @click.stop="handleSelectedChipRemove">
<view class="selected-chip-close" :data-wx-key="sel._wxKey" @click.stop="handleSelectedChipRemove">
<u-icon name="close" size="22" color="#8A92A3"></u-icon>
</view>
</view>
@@ -174,6 +174,7 @@
<script>
// 保留所有原有逻辑代码与注释
import { getProductListDoctorReception, getChineseMedicineQuickGramsApi } from '@/api/reception.js';
import { withWxKey } from '@/utils/wxListKey.js';
export default {
name: 'ChineseMedicineModal',
@@ -217,7 +218,7 @@ export default {
value(newVal) {
this.show = newVal;
if (newVal) {
this.selectedDrugs = JSON.parse(JSON.stringify(this.currentDrugs));
this.selectedDrugs = this.mapSelectedDrugs(JSON.parse(JSON.stringify(this.currentDrugs)));
this.fetchQuickGrams();
const kw = (this.initialSearchKey || '').trim();
if (kw) {
@@ -261,9 +262,16 @@ export default {
/**
* 点击已选 chip用药名搜索列表小程序端勿在 @click 传对象,用 data-six + dataset
*/
mapSelectedDrugs(list) {
return withWxKey(list || [], 'index_id', 'sch');
},
findSelectedChipIndex(wxKey) {
return this.selectedDrugs.findIndex((s) => s._wxKey === wxKey);
},
handleSelectedChipSearch(e) {
const six = Number(e && e.currentTarget && e.currentTarget.dataset ? e.currentTarget.dataset.six : NaN);
if (Number.isNaN(six)) return;
const wxKey = e && e.currentTarget && e.currentTarget.dataset && e.currentTarget.dataset.wxKey;
const six = this.findSelectedChipIndex(wxKey);
if (six < 0) return;
const sel = this.selectedDrugs[six];
if (!sel) return;
const name = String(sel.drug_name || sel.name || '').trim();
@@ -278,8 +286,9 @@ export default {
* 从已选条移除一味(不同步二次确认)
*/
handleSelectedChipRemove(e) {
const six = Number(e && e.currentTarget && e.currentTarget.dataset ? e.currentTarget.dataset.six : NaN);
if (Number.isNaN(six) || six < 0 || six >= this.selectedDrugs.length) return;
const wxKey = e && e.currentTarget && e.currentTarget.dataset && e.currentTarget.dataset.wxKey;
const six = this.findSelectedChipIndex(wxKey);
if (six < 0 || six >= this.selectedDrugs.length) return;
this.selectedDrugs.splice(six, 1);
this.emitSelect();
const name = (this.searchKey || '').trim();
@@ -481,14 +490,18 @@ export default {
} else if (drug.name) {
drugName = drug.name;
}
const indexId = drug.id;
const entityId = (drug.drug && drug.drug.id) || drug.id;
const wxKeyBase = indexId != null && indexId !== '' ? String(indexId) : String(entityId || '');
return {
index_id: drug.id,
id: (drug.drug && drug.drug.id) || drug.id,
index_id: indexId,
id: entityId,
drug_name: drugName,
number: drug._quantity,
price: drug.price || 0,
way_id: (drug.drug && drug.drug.way_id) || drug.way_id || 0,
select_number: 1
select_number: 1,
_wxKey: wxKeyBase ? `sch-${wxKeyBase}` : `sch${this.selectedDrugs.length}`,
};
},

View File

@@ -179,6 +179,7 @@
officeList,
newChek
} from '../../../../api/all';
import { chooseAvatarImage } from '@/common/js/select-avatar-image.js';
// } from '@/api/all.js'
export default {
@@ -338,58 +339,25 @@
uni.hideLoading()
},
selectAct() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: (res) => {
uni.showLoading({
title: '请稍后...'
})
const tempFiles = res.tempFiles;
let resSize = tempFiles[0].size;
// 1M=1024KB=1048576B
console.log(resSize)
if (resSize > 1048576) {
uni.showToast({
title: "上传图片大小不能超过1MB",
icon: 'error'
});
return
}
uni.uploadFile({
url: 'https://api.xiaokang88.com/open-api/upload/old-admin-img',
filePath: res.tempFiles[0]['path'],
name: 'file',
header: {
authorization: `Bearer ${uni.getStorageSync('token')}`
},
formData: {
store_id: '11001'
},
success: res => {
let req = this.$u.test.jsonString(res.data) ? JSON.parse(res
.data) : res.data
if (req.errcode == 0) {
this.avatarShow = false
this.form.avatar = req.data.url
uni.hideLoading()
} else {
this.$toast(res.msg)
}
},
fail: e => {
this.avatarShow = false
},
});
chooseAvatarImage({
formData: {
store_id: '11001',
},
complete: (res) => {
if (res.errMsg == "chooseImage:fail cancel") {
this.avatarShow = false
onSuccess: (res) => {
const req = this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
if (req.errcode == 0) {
this.avatarShow = false;
this.form.avatar = req.data.url;
} else {
this.$toast(res.msg);
}
}
},
onCancel: () => {
this.avatarShow = false;
},
onFail: () => {
this.avatarShow = false;
},
});
},
checkboxChange(e, id) {