更换正式环境,测试修改
This commit is contained in:
@@ -20,112 +20,96 @@
|
||||
<view> 预警值 </view>
|
||||
<view> <input type="number" placeholder="请输入预警值" v-model="datas.form.conWarning" name="" id=""> </view>
|
||||
</view>
|
||||
<view style="justify-content: space-between;">
|
||||
<view v-if="!datas.form.id" style="justify-content: space-between;">
|
||||
<view> 耗材类型 </view>
|
||||
<view style="width: 54%;" @tap="datas.showStatus = !datas.showStatus">
|
||||
{{datas.typelist[datas.nowStatusIndex]}}
|
||||
<view style="width: 54%;" @tap="datas.show = !datas.show">
|
||||
{{datas.consGroupName||'请选择耗材类型'}}
|
||||
</view>
|
||||
<uni-icons type="bottom" size="16"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{height:datas.showStatus?statusHeight:0}" class="tranistion status overflow-hide">
|
||||
<view @tap="changeNowStatusIndex(index)" class="u-flex u-p-l-30 lh30 u-p-r-30 u-row-between"
|
||||
v-for="(item,index) in datas.typelist" :key="index">
|
||||
<view :class="{'color-main':datas.nowStatusIndex===index}">{{item}}</view>
|
||||
<uni-icons v-if="datas.nowStatusIndex===index" type="checkmarkempty" :color="color.ColorMain"></uni-icons>
|
||||
</view>
|
||||
<view :style="{height: '14px'}"></view>
|
||||
</view>
|
||||
|
||||
<view class="bottombutton">
|
||||
<up-button type="primary" style="background-color: #318AFE;color: #fff;" @tap="sumbit" :plain="true"
|
||||
text="保存"></up-button>
|
||||
</view>
|
||||
<up-picker :show="datas.show" :columns="datas.typeList" keyName="name" @cancel="datas.show=false" @confirm="confirmConsGroup" ></up-picker>
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
reactive,
|
||||
computed,
|
||||
onMounted,
|
||||
getCurrentInstance
|
||||
} from 'vue';
|
||||
import {
|
||||
tbConsTypeList,
|
||||
tbConsInfoAddlist
|
||||
} from '@/http/yskApi/requestAll.js';
|
||||
import color from '@/commons/color.js';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import { getConsGrpupList,addCons } from '@/http/api/cons.js';
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
|
||||
import { getConsGrpupList, addCons, editCons } from '@/http/api/cons.js';
|
||||
|
||||
let datas = reactive({
|
||||
show: false,
|
||||
form: {
|
||||
conWarning: 999
|
||||
conUnit: '',
|
||||
conName: '',
|
||||
price: '',
|
||||
conWarning: 999,
|
||||
consGroupId: null,
|
||||
},
|
||||
showStatus: false,
|
||||
list: [],
|
||||
typelist: [],
|
||||
nowStatusIndex: 0
|
||||
consGroupName: '',
|
||||
typeList: [],
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
gettbConsTypeList()
|
||||
onLoad((options) => {
|
||||
if( options && options.item ) {
|
||||
let obj = JSON.parse(options.item)
|
||||
datas.form = obj
|
||||
} else {
|
||||
gettbConsTypeList()
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: !datas.form.id ? '添加耗材' : '编辑耗材'
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取耗材类别
|
||||
*/
|
||||
let gettbConsTypeList = () => {
|
||||
datas.typelist = []
|
||||
getConsGrpupList({
|
||||
page: 0,
|
||||
page: 1,
|
||||
size: 30,
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
}).then(res => {
|
||||
datas.list = res
|
||||
res.forEach(ele => {
|
||||
datas.typelist.push(ele.name)
|
||||
})
|
||||
datas.typeList = [res]
|
||||
})
|
||||
}
|
||||
const refs = getCurrentInstance()
|
||||
let sumbit = () => {
|
||||
|
||||
function confirmConsGroup(e){
|
||||
datas.show = false
|
||||
datas.form.consGroupId = e.value[0].id
|
||||
datas.consGroupName = e.value[0].name
|
||||
}
|
||||
|
||||
let sumbit = async () => {
|
||||
let conUnitdata = datas.form.conUnit.replace(/(^\s*)|(\s*$)/g, "")
|
||||
if (!conUnitdata) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "单位不能为空"
|
||||
})
|
||||
uni.$utils.showToast('单位不能为空')
|
||||
return
|
||||
}
|
||||
if (!datas.form.price) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "价格不能为空"
|
||||
})
|
||||
uni.$utils.showToast('价格不能为空')
|
||||
return
|
||||
}
|
||||
console.log(datas.list, 'tiaoshi1')
|
||||
console.log(datas.list[datas.nowStatusIndex], 'tiaoshi1')
|
||||
addCons({
|
||||
...datas.form,
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
consGroupId: datas.list[datas.nowStatusIndex].id
|
||||
}).then(res => {
|
||||
// go.to('PAGES_SALES_CONSUMABLES')
|
||||
go.back()
|
||||
})
|
||||
if (!datas.form.consGroupId) {
|
||||
uni.$utils.showToast('耗材类型不能为空')
|
||||
return
|
||||
}
|
||||
if ( !datas.form.id) {
|
||||
await addCons({...datas.form})
|
||||
} else {
|
||||
await editCons({...datas.form})
|
||||
}
|
||||
uni.navigateBack()
|
||||
}
|
||||
const statusHeight = computed(() => {
|
||||
return 30 * datas.typelist.length + 14 + 'px'
|
||||
})
|
||||
|
||||
function changeNowStatusIndex(i) {
|
||||
datas.nowStatusIndex = i
|
||||
datas.showStatus = false
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
page {
|
||||
|
||||
Reference in New Issue
Block a user