将页面的商品名称转拼音改为接口的方式

This commit is contained in:
jishenghua 2024-11-14 00:02:26 +08:00
parent 1173578859
commit fccfd83c99
3 changed files with 17 additions and 14 deletions

View File

@ -12,7 +12,6 @@
"ant-design-vue": "1.5.2",
"area-data": "^5.0.6",
"axios": "^0.18.0",
"chinese-to-pinyin": "^1.0.2",
"clipboard": "^2.0.4",
"codemirror": "^5.46.0",
"dayjs": "^1.8.0",

View File

@ -61,6 +61,7 @@ const getMaterialByBarCode = (params)=>getAction("/material/getMaterialByBarCode
const getMaxBarCode = (params)=>getAction("/material/getMaxBarCode",params);
const checkMaterialBarCode = (params)=>getAction("/materialsExtend/checkIsBarCodeExist",params);
const batchUpdateMaterial = (params)=>postAction("/material/batchUpdate",params);
const changeNameToPinYin = (params)=>postAction("/material/changeNameToPinYin",params);
//序列号
const addSerialNumber = (params)=>postAction("/serialNumber/add",params);
const editSerialNumber = (params)=>putAction("/serialNumber/update",params);
@ -163,6 +164,7 @@ export {
getMaxBarCode,
checkMaterialBarCode,
batchUpdateMaterial,
changeNameToPinYin,
addSerialNumber,
editSerialNumber,
checkSerialNumber,

View File

@ -295,10 +295,9 @@
import JEditableTable from '@/components/jeecg/JEditableTable'
import { FormTypes, getRefPromise, VALIDATE_NO_PASSED, validateFormAndTables } from '@/utils/JEditableTableUtil'
import { checkMaterial, checkMaterialBarCode, getMaterialAttributeNameList,
getMaterialAttributeValueListById, getMaxBarCode, queryMaterialCategoryTreeList } from '@/api/api'
getMaterialAttributeValueListById, getMaxBarCode, queryMaterialCategoryTreeList, changeNameToPinYin } from '@/api/api'
import { removeByVal, autoJumpNextInput, handleIntroJs } from '@/utils/util'
import { getAction, httpAction } from '@/api/manage'
import Pinyin from 'chinese-to-pinyin'
import JImageUpload from '@/components/jeecg/JImageUpload'
import JDate from '@/components/jeecg/JDate'
import Vue from 'vue'
@ -346,6 +345,7 @@
manySkuSelected: 0,
model: {},
showOkFlag: true,
setTimeFlag: null,
labelCol: {
xs: { span: 24 },
sm: { span: 8 },
@ -1109,20 +1109,22 @@
}
},
handleNameChange(e) {
let that = this
if(e.target.value) {
let pyArr = []
e.target.value.split("").forEach(w => {
w = w.trim()
if (w) {
if (/[\u4e00-\u9fa5]/.test(w)) {
let py = Pinyin(w, {removeTone: true, keepRest: true}).trim()
pyArr.push(py.substring(0, 1))
if(this.setTimeFlag != null){
clearTimeout(this.setTimeFlag)
}
this.setTimeFlag = setTimeout(()=>{
changeNameToPinYin({name: e.target.value}).then((res) => {
if (res && res.code === 200) {
that.form.setFieldsValue({'mnemonic':res.data})
} else {
pyArr.push(w)
that.$message.warning(res.data)
}
}
})
this.form.setFieldsValue({'mnemonic':pyArr.join("")})
})
},500)
} else {
that.form.setFieldsValue({'mnemonic':''})
}
},
onlyUnitOnChange(e) {