diff --git a/components/inputAndSelect/inputAndSelect.vue b/components/inputAndSelect/inputAndSelect.vue
index f9047f7..eb3b1c7 100644
--- a/components/inputAndSelect/inputAndSelect.vue
+++ b/components/inputAndSelect/inputAndSelect.vue
@@ -26,13 +26,21 @@
scroll-y="true"
:style="{ height: listHeight + 'rpx' }"
>
+
+ 新增“{{ normalizedSearchText }}”
+
+
- {{ item.label }}
+ {{ item.label }}
{
+ if (!item || typeof item !== 'object') {
+ return false;
+ }
+
+ const label = String(item.label || '').trim().toLowerCase();
+ return label === this.normalizedSearchText.toLowerCase();
+ });
}
},
data() {
@@ -96,11 +131,41 @@
}
},
methods: {
+ normalizeInputText(raw) {
+ if (typeof raw === 'string') {
+ return raw;
+ }
+ if (typeof raw === 'number') {
+ return String(raw);
+ }
+ if (raw && typeof raw === 'object') {
+ if (typeof raw.detail === 'string') {
+ return raw.detail;
+ }
+ if (raw.detail && typeof raw.detail.value === 'string') {
+ return raw.detail.value;
+ }
+ if (raw.target && typeof raw.target.value === 'string') {
+ return raw.target.value;
+ }
+ if (typeof raw.value === 'string') {
+ return raw.value;
+ }
+ }
+ return '';
+ },
handleClose() {
this.$emit('close');
},
- handleSearch() {
+ handleSearch(raw) {
+ if (typeof raw !== 'undefined') {
+ const nextText = this.normalizeInputText(raw);
+ if (nextText !== this.searchText) {
+ this.searchText = nextText;
+ }
+ }
+
if (!this.searchText.trim()) {
this.filteredList = [...this.list];
return;
@@ -126,6 +191,15 @@
this.$emit('change', null);
// 关闭弹窗
this.$emit('close');
+ },
+ handleCreate() {
+ const value = this.normalizedSearchText;
+ if (!value) {
+ return;
+ }
+
+ this.$emit('create', value);
+ this.$emit('close');
}
}
}
@@ -223,5 +297,14 @@
border-bottom: none;
}
}
+
+ .list-item--create {
+ background: #f4f8ff;
+ }
+
+ .item-text--create {
+ color: #2979ff !important;
+ font-weight: 600;
+ }
}
\ No newline at end of file
diff --git a/core/request/apis.js b/core/request/apis.js
index d3ae0c7..2aaa134 100644
--- a/core/request/apis.js
+++ b/core/request/apis.js
@@ -178,6 +178,30 @@ export default {
auth: true,
method: "POST",
isSystemApi: true
+ },
+ getProhibitedType: {
+ path: "stock.warehouse.getProhibitedType",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ getStockUnits: {
+ path: "stock.warehouse.getStockUnits",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ checkItemCodeUnique: {
+ path: "stock.warehouse.checkItemCodeUnique",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
+ },
+ saveWarehouseStock: {
+ path: "stock.warehouse.saveWarehouseStock",
+ auth: true,
+ method: "POST",
+ isSystemApi: true
}
}
},
diff --git a/core/utils/tool.js b/core/utils/tool.js
index e67cc90..53e6300 100644
--- a/core/utils/tool.js
+++ b/core/utils/tool.js
@@ -4,6 +4,7 @@ import {
import {
router
} from '@/core/router'
+import voice from './voice'
export default {
normalizeRoutePath(path = '') {
return String(path || '')
@@ -140,6 +141,24 @@ export default {
});
},
+ /**
+ * 语音播报
+ * @param {String} text - 播报内容
+ * @param {Object} options - 播报选项
+ * @return {Promise}
+ */
+ speakText(text = '', options = {}) {
+ return voice.speak(text, options);
+ },
+
+ /**
+ * 停止语音播报
+ * @return {Boolean}
+ */
+ stopSpeak() {
+ return voice.stop();
+ },
+
/**
* 微信头像
* @param {String} url -图片地址
diff --git a/core/utils/voice.js b/core/utils/voice.js
new file mode 100644
index 0000000..db7b2f5
--- /dev/null
+++ b/core/utils/voice.js
@@ -0,0 +1,222 @@
+class VoiceBroadcastManager {
+ constructor() {
+ this.tts = null;
+ this.initPromise = null;
+ this.initListener = null;
+ this.lastText = '';
+ this.lastSpeakAt = 0;
+ }
+
+ isSupported() {
+ return typeof plus !== 'undefined' && (!!plus.speech || !!plus.android);
+ }
+
+ hasNativeSpeech() {
+ return typeof plus !== 'undefined' && !!plus.speech && typeof plus.speech.speak === 'function';
+ }
+
+ async speakByNative(text, options = {}) {
+ if (!this.hasNativeSpeech()) {
+ return false;
+ }
+
+ return new Promise(resolve => {
+ try {
+ const speechOptions = {
+ volume: Number(options.volume || 1),
+ speechRate: Number(options.rate || 1),
+ pitch: Number(options.pitch || 1)
+ };
+
+ try {
+ plus.speech.stop();
+ } catch (error) {
+ console.warn('[VoiceBroadcast] 停止旧播报失败:', error);
+ }
+
+ plus.speech.speak(
+ String(text || ''),
+ () => {
+ resolve(true);
+ },
+ error => {
+ console.warn('[VoiceBroadcast] 原生语音播报失败:', error);
+ resolve(false);
+ },
+ speechOptions
+ );
+ } catch (error) {
+ console.error('[VoiceBroadcast] 调用原生语音能力异常:', error);
+ resolve(false);
+ }
+ });
+ }
+
+ async ensureReady() {
+ if (!this.isSupported()) {
+ return false;
+ }
+
+ if (this.hasNativeSpeech()) {
+ return true;
+ }
+
+ if (this.tts) {
+ return true;
+ }
+
+ if (this.initPromise) {
+ return this.initPromise;
+ }
+
+ this.initPromise = new Promise(resolve => {
+ try {
+ const mainActivity = plus.android.runtimeMainActivity();
+ if (!mainActivity) {
+ this.initPromise = null;
+ resolve(false);
+ return;
+ }
+
+ const TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech');
+ const Locale = plus.android.importClass('java.util.Locale');
+ const successCode = typeof TextToSpeech.SUCCESS === 'number' ? TextToSpeech.SUCCESS : 0;
+
+ this.initListener = plus.android.implements('android.speech.tts.TextToSpeech$OnInitListener', {
+ onInit: status => {
+ try {
+ if (status !== successCode && status !== 0) {
+ console.warn('[VoiceBroadcast] TTS 初始化失败, status:', status);
+ resolve(false);
+ return;
+ }
+
+ if (this.tts && typeof this.tts.setLanguage === 'function') {
+ const locale = Locale.CHINA || Locale.CHINESE || Locale.SIMPLIFIED_CHINESE || Locale.getDefault();
+ this.tts.setLanguage(locale);
+ this.tts.setPitch(1.0);
+ this.tts.setSpeechRate(1.0);
+ }
+
+ resolve(true);
+ } catch (error) {
+ console.error('[VoiceBroadcast] TTS 初始化异常:', error);
+ resolve(false);
+ } finally {
+ this.initPromise = null;
+ }
+ }
+ });
+
+ this.tts = new TextToSpeech(mainActivity, this.initListener);
+ } catch (error) {
+ console.error('[VoiceBroadcast] 创建 TTS 实例失败:', error);
+ this.tts = null;
+ this.initListener = null;
+ this.initPromise = null;
+ resolve(false);
+ }
+ });
+
+ return this.initPromise;
+ }
+
+ async speak(text = '', options = {}) {
+ const content = String(text || '').trim();
+ if (!content) {
+ return false;
+ }
+
+ const now = Date.now();
+ const minInterval = Number(options.minInterval || 600);
+ if (!options.force && this.lastText === content && now - this.lastSpeakAt < minInterval) {
+ return false;
+ }
+
+ if (this.hasNativeSpeech()) {
+ const nativeResult = await this.speakByNative(content, options);
+ if (nativeResult) {
+ this.lastText = content;
+ this.lastSpeakAt = Date.now();
+ return true;
+ }
+ }
+
+ const ready = await this.ensureReady();
+ if (!ready || !this.tts) {
+ return false;
+ }
+
+ try {
+ const TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech');
+ const queueMode = options.flush === false
+ ? (typeof TextToSpeech.QUEUE_ADD === 'number' ? TextToSpeech.QUEUE_ADD : 1)
+ : (typeof TextToSpeech.QUEUE_FLUSH === 'number' ? TextToSpeech.QUEUE_FLUSH : 0);
+ const rate = Number(options.rate || 1);
+ const pitch = Number(options.pitch || 1);
+
+ if (typeof this.tts.setSpeechRate === 'function') {
+ this.tts.setSpeechRate(rate);
+ }
+ if (typeof this.tts.setPitch === 'function') {
+ this.tts.setPitch(pitch);
+ }
+
+ const normalizedContent = content.replace(/\s+/g, ' ');
+ const utteranceId = `voice_${now}`;
+
+ try {
+ this.tts.speak(normalizedContent, queueMode, null, utteranceId);
+ } catch (error) {
+ this.tts.speak(normalizedContent, queueMode, null);
+ }
+
+ this.lastText = content;
+ this.lastSpeakAt = Date.now();
+ return true;
+ } catch (error) {
+ console.error('[VoiceBroadcast] 语音播报失败:', error);
+ return false;
+ }
+ }
+
+ stop() {
+ if (this.hasNativeSpeech()) {
+ try {
+ plus.speech.stop();
+ return true;
+ } catch (error) {
+ console.error('[VoiceBroadcast] 停止原生播报失败:', error);
+ }
+ }
+
+ if (!this.tts || typeof this.tts.stop !== 'function') {
+ return false;
+ }
+
+ try {
+ this.tts.stop();
+ return true;
+ } catch (error) {
+ console.error('[VoiceBroadcast] 停止播报失败:', error);
+ return false;
+ }
+ }
+
+ destroy() {
+ try {
+ this.stop();
+ if (this.tts && typeof this.tts.shutdown === 'function') {
+ this.tts.shutdown();
+ }
+ } catch (error) {
+ console.error('[VoiceBroadcast] 销毁播报器失败:', error);
+ } finally {
+ this.tts = null;
+ this.initPromise = null;
+ this.initListener = null;
+ }
+ }
+}
+
+export default new VoiceBroadcastManager();
\ No newline at end of file
diff --git a/pages.json b/pages.json
index afcd1cb..58d103f 100644
--- a/pages.json
+++ b/pages.json
@@ -134,6 +134,13 @@
{
"titleNView": false
}
+ },
+ {
+ "path" : "pages/work/product/edit",
+ "style" :
+ {
+ "titleNView": false
+ }
}
],
diff --git a/pages/work/product/detail.vue b/pages/work/product/detail.vue
index c13e1c8..077d93b 100644
--- a/pages/work/product/detail.vue
+++ b/pages/work/product/detail.vue
@@ -1,7 +1,20 @@
-
+
+
+
+ 修改
+
+
+