This commit is contained in:
xuyuncong 2025-10-20 11:41:40 +08:00
parent 9762746eef
commit 5398a129dc
7 changed files with 1645 additions and 1460 deletions

View File

@ -0,0 +1,132 @@
<template>
<view class="date-range-selector">
<u-subsection :list="dateRangeList" keyName="label" :current="selected" @change="handleSubsectionChange" />
<uni-datetime-picker :value="internalDateRange" type="daterange" @change="handleDatePickerChange" />
</view>
</template>
<script>
export default {
props: {
// Vue2 使 value v-model prop
value: {
type: Array,
required: true
},
dateRangeList: {
type: Array,
default: () => [{
label: "今日",
value: "day"
},
{
label: "本周",
value: "week"
},
{
label: "本月",
value: "month"
}
]
}
},
data() {
return {
selected: 0,
internalDateRange: this.value
};
},
watch: {
value(newVal) {
if (JSON.stringify(newVal) !== JSON.stringify(this.internalDateRange)) {
this.internalDateRange = newVal;
this.resetSelectedIndex();
}
},
internalDateRange(newVal) {
this.$emit('input', newVal); // Vue2 使 input
this.$emit('subsection-change', newVal);
}
},
methods: {
//
getDateRange(type) {
const now = new Date()
let start, end
if (type === 'week') {
//
const day = now.getDay() || 7 // Sunday 0 7
start = new Date(now)
start.setDate(now.getDate() - day + 1)
end = new Date(start)
end.setDate(start.getDate() + 6)
} else if (type === 'month') {
//
start = new Date(now.getFullYear(), now.getMonth(), 1)
end = new Date(now.getFullYear(), now.getMonth() + 1, 0) //
} else if (type === 'day') {
// 00:00:00 23:59:59
start = new Date(now)
start.setHours(0, 0, 0, 0)
end = new Date(now)
end.setHours(23, 59, 59, 999)
} else {
console.warn('不支持的类型:', type)
return []
}
return [
this.formatDateCus(start),
this.formatDateCus(end)
]
},
//
formatDateCus(date) {
const y = date.getFullYear()
const m = (date.getMonth() + 1).toString().padStart(2, '0')
const d = date.getDate().toString().padStart(2, '0')
return `${y}-${m}-${d}`
},
handleSubsectionChange(index) {
this.selected = index;
const {
value
} = this.dateRangeList[index];
this.internalDateRange = this.getDateRange(value);
},
handleDatePickerChange(newRange) {
this.internalDateRange = newRange;
this.resetSelectedIndex();
},
resetSelectedIndex() {
const isPreset = this.dateRangeList.some((item, index) => {
const range = this.getDateRange(item.value);
return JSON.stringify(range) === JSON.stringify(this.internalDateRange);
});
if (!isPreset) {
this.selected = -1; //
}
}
},
created() {
//
if (!this.value || this.value.length === 0) {
this.internalDateRange = this.getDateRange('day');
} else {
this.resetSelectedIndex();
}
}
};
</script>
<style scoped>
.date-range-selector {
/* 可以写样式 */
}
</style>

View File

@ -55,11 +55,11 @@
</view> </view>
<view class="finance" v-if="checkPermi(['repair:tick:profit'])"> <view class="finance" v-if="checkPermi(['repair:tick:profit'])">
<view class="fin-card receivable" @click.self="goListByPayStatus('receivable')"> <view class="fin-card receivable" @click="goListByPayStatus('receivable')">
<view class="fin-top"> <view class="fin-top">
<text class="fin-title">应收款</text> <text class="fin-title">应收款</text>
<uni-icons :type="financeVisibility.receivable ? 'eye' : 'eye-slash'" color="#7aa6ff" size="20" <uni-icons :type="financeVisibility.receivable ? 'eye' : 'eye-slash'" color="#7aa6ff" size="20"
@click="toggleFinance('receivable')" /> @click.native.stop="toggleFinance('receivable')" />
</view> </view>
<!-- 已收款金额 --> <!-- 已收款金额 -->
<text <text
@ -69,11 +69,11 @@
<image src="../images/money_one.png" mode="widthFix" class="tap_icon"></image> <image src="../images/money_one.png" mode="widthFix" class="tap_icon"></image>
</view> </view>
</view> </view>
<view class="fin-card collected" @click.self="goListByPayStatus('receivedAmount')"> <view class="fin-card collected" @click="goListByPayStatus('receivedAmount')">
<view class="fin-top"> <view class="fin-top">
<text class="fin-title">已收款</text> <text class="fin-title">已收款</text>
<uni-icons :type="financeVisibility.collected ? 'eye' : 'eye-slash'" color="#a896ff" size="20" <uni-icons :type="financeVisibility.collected ? 'eye' : 'eye-slash'" color="#a896ff" size="20"
@click="toggleFinance('collected')" /> @click.native.stop="toggleFinance('collected')" />
</view> </view>
<text <text
class="fin-amount">{{ financeVisibility.collected ? formatCurrency(otherInfo.receivedAmount) : '*****' }}</text> class="fin-amount">{{ financeVisibility.collected ? formatCurrency(otherInfo.receivedAmount) : '*****' }}</text>
@ -82,11 +82,11 @@
<image src="../images/money_two.png" mode="widthFix" class="tap_icon"></image> <image src="../images/money_two.png" mode="widthFix" class="tap_icon"></image>
</view> </view>
</view> </view>
<view class="fin-card pending" @click.self="goListByPayStatus('pendingAmount')"> <view class="fin-card pending" @click="goListByPayStatus('pendingAmount')">
<view class="fin-top"> <view class="fin-top">
<text class="fin-title">待收款</text> <text class="fin-title">待收款</text>
<uni-icons :type="financeVisibility.pending ? 'eye' : 'eye-slash'" color="#ffcf7a" size="20" <uni-icons :type="financeVisibility.pending ? 'eye' : 'eye-slash'" color="#ffcf7a" size="20"
@click="toggleFinance('pending')" /> @click.native.stop="toggleFinance('pending')" />
</view> </view>
<text <text
class="fin-amount">{{ financeVisibility.pending ? formatCurrency(otherInfo.pendingAmount) : '*****' }}</text> class="fin-amount">{{ financeVisibility.pending ? formatCurrency(otherInfo.pendingAmount) : '*****' }}</text>
@ -123,16 +123,6 @@
queryParams: { queryParams: {
dateRange: [], dateRange: [],
}, },
sectionOrder: ['orders', 'repairing', 'completed', 'settled', 'unsettled', 'delivered', 'inFactory'],
sectionTitle: {
orders: '订单(进厂)数',
repairing: '维修中',
completed: '已竣工',
settled: '竣工已结算',
unsettled: '竣工未结算',
delivered: '已交车',
inFactory: '在厂数'
},
tapList: [{ tapList: [{
label: "本日", label: "本日",
value: "day", value: "day",

View File

@ -877,16 +877,16 @@
getCarList(carId) { getCarList(carId) {
const params = { const params = {
userId: this.userInfo.userId, id: this.userInfo.id,
pageNo: 1, pageNo: 1,
pageSize: 100000 pageSize: 100000
} }
request({ request({
url: '/admin-api/base/carMain/page', url: '/admin-api/base/custom/get',
method: 'GET', method: 'GET',
params: params params: params
}).then(res => { }).then(res => {
this.carList = res.data.records this.carList = res.data.carList
for (let i = 0; i < this.carList.length; i++) { for (let i = 0; i < this.carList.length; i++) {
if (this.carList[i].licenseNumber.toLowerCase() == this.phone.toLowerCase()) { if (this.carList[i].licenseNumber.toLowerCase() == this.phone.toLowerCase()) {
this.activeCarIndex = i this.activeCarIndex = i

View File

@ -19,17 +19,21 @@
<view class="list"> <view class="list">
<scroll-view style="height: 100%" scroll-y="true" class="itemContent" @scrolltolower="onReachBottomCus" <scroll-view style="height: 100%" scroll-y="true" class="itemContent" @scrolltolower="onReachBottomCus"
refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered"> refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
<view v-for="(item, index) in repairList" :key="index" class="listItem"> <view v-for="(item, index) in repairList" :key="index" class="listItem"
@click="addNewWaresFun(item.id)">
<view class="repairName">{{ item.name }}</view> <view class="repairName">{{ item.name }}</view>
<view class="repairBottom"> <view class="repairBottom">
<text class="repairDesc">单位 <text class="repairDesc">单位
<text class="repairUnit">{{ item.unitText }}</text> <text class="repairUnit">{{ item.unitText }}</text>
</text> </text>
<text class="repairDesc">当前库存
<text class="repairUnit">{{ item.stock }}</text>
</text>
<view class="repairBtns"> <view class="repairBtns">
<u-icon name="minus-circle-fill" size="24" @click="delNum(item)"></u-icon> <u-icon name="minus-circle-fill" size="24" @click.native.stop="delNum(item)"></u-icon>
<text class="repairNum">{{ item.num }}</text> <text class="repairNum">{{ item.num }}</text>
<u-icon color="#0174F6" name="plus-circle-fill" size="24" <u-icon color="#0174F6" name="plus-circle-fill" size="24"
@click="addNum(item)"></u-icon> @click.native.stop="addNum(item)"></u-icon>
</view> </view>
</view> </view>
</view> </view>
@ -481,10 +485,16 @@
/** /**
* 添加新的配件 * 添加新的配件
*/ */
addNewWaresFun() { addNewWaresFun(id) {
uni.navigateTo({ if (id) {
url: '/pages-repair/apply/newWare' uni.navigateTo({
}) url: `/pages-repair/apply/newWare?id=${id}`
})
} else {
uni.navigateTo({
url: `/pages-repair/apply/newWare`
})
}
}, },
} }
} }

View File

@ -1,417 +1,546 @@
<template> <template>
<view class="container"> <view class="container">
<VNavigationBar background-color="#fff" title="新增配件" title-color="#333"></VNavigationBar> <VNavigationBar background-color="#fff" :title="title" title-color="#333"></VNavigationBar>
<view class="listBox"> <view class="listBox">
<view class="list"> <view class="list">
<view class="formItem"> <view class="formItem">
<text class="formLabel require">配件名称</text> <text class="formLabel require">配件名称</text>
<input type="text" style="text-align: right" v-model="formData.name" placeholder="请输入配件名称"/> <input type="text" style="text-align: right" v-model="formData.name" placeholder="请输入配件名称" />
</view> </view>
<view class="formItem"> <view class="formItem">
<text class="formLabel require">所属分类</text> <text class="formLabel require">进价</text>
<picker @change="typePickerChange" :value="typeIndex" :range="allTypeNameList"> <input type="text" style="text-align: right" v-model="formData.purPrice" placeholder="请输入配件名称" />
<view class="uni-input">{{allTypeNameList[typeIndex]}}</view> </view>
</picker> <view class="formItem">
</view> <text class="formLabel require">销售价格</text>
<view class="formItem"> <input type="text" style="text-align: right" v-model="formData.price" placeholder="请输入配件名称" />
<text class="formLabel require">计量单位</text> </view>
<picker @change="unitPickerChange" :value="unitIndex" :range="allUnitNameList"> <view class="formItem">
<view class="uni-input">{{allUnitNameList[unitIndex]}}</view> <text class="formLabel require">所属分类</text>
</picker> <picker @change="typePickerChange" :value="typeIndex" :range="allTypeNameList">
</view> <view class="uni-input">{{allTypeNameList[typeIndex]}}</view>
<view class="formItem"> </picker>
<text class="formLabel">规格型号</text> </view>
<input type="text" style="text-align: right" v-model="formData.model" placeholder="请输入规格型号"/> <view class="formItem">
</view> <text class="formLabel require">计量单位</text>
<view class="formItem"> <picker @change="unitPickerChange" :value="unitIndex" :range="allUnitNameList">
<text class="formLabel">来源</text> <view class="uni-input">{{allUnitNameList[unitIndex]}}</view>
<picker @change="fromPickerChange" :value="fromIndex" :range="allFromNameList"> </picker>
<view class="uni-input">{{allFromNameList[fromIndex]}}</view> </view>
</picker> <view class="formItem">
</view> <text class="formLabel">规格型号</text>
<view class="formItem"> <input type="text" style="text-align: right" v-model="formData.model" placeholder="请输入规格型号" />
<text class="formLabel">配件属性</text> </view>
<picker @change="attributePickerChange" :value="attributeIndex" :range="allAttributeNameList"> <view class="formItem">
<view class="uni-input">{{allAttributeNameList[attributeIndex]}}</view> <text class="formLabel">来源</text>
</picker> <picker @change="fromPickerChange" :value="fromIndex" :range="allFromNameList">
</view> <view class="uni-input">{{allFromNameList[fromIndex]}}</view>
<view class="formItem"> </picker>
<text class="formLabel">状态</text> </view>
<view> <view class="formItem">
<radio-group v-model="formData.status"> <text class="formLabel">配件属性</text>
<label class="radio-label" v-for="(item, index) in radioOptions" :key="index"> <picker @change="attributePickerChange" :value="attributeIndex" :range="allAttributeNameList">
<radio :value="item.value" :checked="item.checked">{{ item.label }}</radio> <view class="uni-input">{{allAttributeNameList[attributeIndex]}}</view>
</label> </picker>
</radio-group> </view>
</view> <view class="formItem">
</view> <text class="formLabel">状态</text>
<view class="formItem"> <view>
<text class="formLabel">条形码</text> <radio-group v-model="formData.status">
<input type="text" style="text-align: right" v-model="formData.barCode" placeholder="请输入条形码"/> <label class="radio-label" v-for="(item, index) in radioOptions" :key="index">
</view> <radio :value="item.value" :checked="item.checked">{{ item.label }}</radio>
<view class="formItem"> </label>
<text class="formLabel">商品编码</text> </radio-group>
<input type="text" style="text-align: right" v-model="formData.code" placeholder="请输入商品编码"/> </view>
</view> </view>
<view class="formItem"> <view class="formItem">
<text class="formLabel">适用子公司</text> <text class="formLabel">条形码</text>
<text class="formValue"></text> <input type="text" style="text-align: right" v-model="formData.barCode" placeholder="请输入条形码" />
</view> </view>
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem"> <view class="formItem">
<checkbox-group v-model="checkedCorpIdList" @change="cs"> <text class="formLabel">商品编码</text>
<checkbox v-for="(item, index) in allCompanyList" :key="index" :value="item.id" :checked="item.checked">{{ item.corpName }}</checkbox> <input type="text" style="text-align: right" v-model="formData.code" placeholder="请输入商品编码" />
</checkbox-group> </view>
</view> <view class="formItem">
<view class="formItem"> <text class="formLabel">适用子公司</text>
<text class="formLabel">适用车型</text> <text class="formValue"></text>
<text class="formValue"></text> </view>
</view> <view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem">
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem"> <checkbox-group v-model="checkedCorpIdList" @change="cs">
<textarea style="height: 50px" auto-height placeholder="请输入适用车型" v-model="formData.carModel" /> <checkbox v-for="(item, index) in allCompanyList" :key="index" :value="item.id"
</view> :checked="item.checked">{{ item.corpName }}</checkbox>
<view class="formItem"> </checkbox-group>
<text class="formLabel">备注</text> </view>
<text class="formValue"></text> <view class="formItem">
</view> <text class="formLabel">适用车型</text>
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem"> <text class="formValue"></text>
<textarea style="height: 50px" auto-height placeholder="请输入备注" v-model="formData.remark" /> </view>
</view> <view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem">
</view> <textarea style="height: 50px" auto-height placeholder="请输入适用车型" v-model="formData.carModel" />
</view> </view>
<view class="footer"> <view class="formItem">
<text class="label"></text> <text class="formLabel">备注</text>
<text class="repairNum"></text> <text class="formValue"></text>
<view class="submit" @click="submit">保存</view> </view>
</view> <view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem">
</view> <textarea style="height: 50px" auto-height placeholder="请输入备注" v-model="formData.remark" />
</view>
</view>
</view>
<view class="footer">
<text class="label"></text>
<text class="repairNum"></text>
<view class="submit" @click="submit">保存</view>
</view>
</view>
</template> </template>
<script> <script>
import VNavigationBar from "@/components/VNavigationBar.vue"; import VNavigationBar from "@/components/VNavigationBar.vue";
import request from '@/utils/request'; import request from '@/utils/request';
import {getDictTextByCodeAndValue,createUniqueCodeByHead} from "@/utils/utils"; import {
import {getUserInfo,getJSONData} from '@/utils/auth.js' getDictTextByCodeAndValue,
createUniqueCodeByHead
} from "@/utils/utils";
import {
getUserInfo,
getJSONData
} from '@/utils/auth.js'
export default { export default {
components: {VNavigationBar}, components: {
data() { VNavigationBar
return { },
// data() {
formData:{ return {
name:"", //
type:"", formData: {
unit:"", name: "",
model:"", type: "",
dataForm:"", unit: "",
attribute:"", model: "",
status:"", dataForm: "",
barCode:"", attribute: "",
code:"", status: "",
corpId:"", barCode: "",
carModel:"", code: "",
remark:"", corpId: "",
}, carModel: "",
// remark: "",
radioOptions: [ },
{ label: '启用', value: '01' ,checked:true}, //
{ label: '禁用', value: '02' ,checked:false} radioOptions: [{
], label: '启用',
// value: '01',
allTypeList:[], checked: true
//- },
allTypeNameList:[], {
// label: '禁用',
typeIndex:0, value: '02',
// checked: false
allUnitList:[], }
//- ],
allUnitNameList:[], //
// allTypeList: [],
unitIndex:0, //-
// allTypeNameList: [],
allFromList:[], //
//- typeIndex: 0,
allFromNameList:[], //
// allUnitList: [],
fromIndex:0, //-
// allUnitNameList: [],
allAttributeList:[], //
//- unitIndex: 0,
allAttributeNameList:[], //
// allFromList: [],
attributeIndex:0, //-
// allFromNameList: [],
allCompanyList:[], //
//id fromIndex: 0,
checkedCorpIdList:[], //
}; allAttributeList: [],
}, //-
onLoad() { allAttributeNameList: [],
this.init() //
}, attributeIndex: 0,
computed: { //
allCompanyList: [],
//id
checkedCorpIdList: [],
//
title: '新增配件',
};
},
onLoad(options) {
if (options.id) {
this.title = '修改配件'
//
this.init().then(() => {
this.selectWares(options.id)
})
} else {
this.init()
}
},
computed: {
}, },
methods: { methods: {
cs(e){ cs(e) {
this.checkedCorpIdList =e.detail.value this.checkedCorpIdList = e.detail.value
}, },
/** /**
* 初始化配件数据 * 初始化配件数据
*/ */
init() { async init() {
// try {
this.selectBaseType() //
// await Promise.all([
this.selectBaseUnit() this.selectBaseType(),
// this.selectBaseUnit(),
this.selectDataFrom() this.selectDataFrom(),
// this.selectAttribute(),
this.selectAttribute() this.selectCompany()
// ])
this.selectCompany() } catch (error) {
}, console.error('初始化数据失败:', error)
/** }
* 查所有可选分类 },
*/ /**
selectBaseType(){ * 查所有可选分类
request({ */
url: '/admin-api/conf/baseType/list', selectBaseType() {
method: 'get', request({
params: {type:"02"} url: '/admin-api/conf/baseType/list',
}).then((res) => { method: 'get',
console.log(res) params: {
if (res.code == 200 && res.data.length>0) { type: "02"
this.allTypeList = res.data }
this.allTypeNameList = res.data.map((item)=>{return item.name}) }).then((res) => {
} console.log(res)
}) if (res.code == 200 && res.data.length > 0) {
}, this.allTypeList = res.data
/** this.allTypeNameList = res.data.map((item) => {
* 查所有可选计量单位 return item.name
*/ })
selectBaseUnit(){ }
request({ })
url: '/admin-api/system/dict-data/type', },
method: 'get', /**
params:{type:"repair_unit"} * 查所有可选计量单位
}).then((res) => { */
console.log(res) selectBaseUnit() {
if (res.code == 200) { request({
this.allUnitList = res.data url: '/admin-api/system/dict-data/type',
this.allUnitNameList = res.data.map((item)=>{return item.label}) method: 'get',
} params: {
}) type: "repair_unit"
}, }
/** }).then((res) => {
* 查所有可选来源 console.log(res)
*/ if (res.code == 200) {
selectDataFrom(){ this.allUnitList = res.data
request({ this.allUnitNameList = res.data.map((item) => {
url: '/admin-api/system/dict-data/type', return item.label
method: 'get', })
params:{type:"wares_data_form"} }
}).then((res) => { })
console.log(res) },
if (res.code == 200) { /**
this.allFromList = res.data * 查询配件信息
this.allFromNameList = res.data.map((item)=>{return item.label}) */
} selectWares(id) {
}) request({
}, url: `/admin-api/repair/wares/get`,
/** method: 'get',
* 查所有可选属性 params: {
*/ id
selectAttribute(){ }
request({ }).then((res) => {
url: '/admin-api/system/dict-data/type', if (res.code === 200 && res.data) {
method: 'get', this.formData = res.data
params:{type:"wares_attribute"}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allAttributeList = res.data
this.allAttributeNameList = res.data.map((item)=>{return item.label})
}
})
},
/**
* 查所有可选子公司
*/
selectCompany(){
request({
url: '/admin-api/base/company/list',
method: 'get'
}).then((res) => {
console.log(res)
if (res.code == 200 && res.data.length>0) {
this.allCompanyList = res.data
this.allCompanyList.map((item)=>{
item.checked=false
})
}
})
},
/**
* 选分类
*/
typePickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.typeIndex = e.detail.value
},
/**
* 选计量单位
*/
unitPickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.unitIndex = e.detail.value
},
/**
* 选来源
*/
fromPickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.fromIndex = e.detail.value
},
/**
* 选属性
*/
attributePickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.attributeIndex = e.detail.value
},
/**
* 新增配件
*/
submit() {
//
if(!this.formData.name){
uni.showToast({
title: '请输入配件名称!',
icon: 'none'
})
return
}
//
console.log(this.allCompanyList,"this.checkedCorpIdList") //
if(this.checkedCorpIdList.length>0){ if (this.allTypeList.length > 0 && res.data.type) {
this.formData.corpId = this.checkedCorpIdList.join() const typeIndex = this.allTypeList.findIndex(item => item.id === res.data.type)
} if (typeIndex !== -1) {
// this.typeIndex = typeIndex
this.formData.status = "01" }
this.formData.type = this.allTypeList[this.typeIndex].id }
this.formData.unit = this.allUnitList[this.unitIndex].value
this.formData.dataForm = this.allFromList[this.fromIndex].value
this.formData.attribute = this.allAttributeList[this.attributeIndex].value
request({
url: '/admin-api/repair/wares/create',
method: 'post',
data:this.formData
}).then((res)=>{
if (res.code == 200){
uni.showToast({
title: '新增成功!',
icon: 'none'
})
setTimeout(()=>{
uni.navigateBack()
},700)
}else{
uni.showToast({
title: '操作失败,请联系管理员!',
icon: 'none'
})
}
})
}
} //
} if (this.allUnitList.length > 0 && res.data.unit) {
const unitIndex = this.allUnitList.findIndex(item => item.value === res.data.unit)
if (unitIndex !== -1) {
this.unitIndex = unitIndex
}
}
//
if (this.allFromList.length > 0 && res.data.dataForm) {
const fromIndex = this.allFromList.findIndex(item => item.value === res.data.dataForm)
if (fromIndex !== -1) {
this.fromIndex = fromIndex
}
}
//
if (this.allAttributeList.length > 0 && res.data.attribute) {
const attributeIndex = this.allAttributeList.findIndex(item => item.value === res.data
.attribute)
if (attributeIndex !== -1) {
this.attributeIndex = attributeIndex
}
}
//
if (res.data.corpIds && res.data.corpIds.length > 0) {
this.checkedCorpIdList = res.data.corpIds
// checkbox
this.allCompanyList.forEach(item => {
item.checked = res.data.corpIds.includes(item.id)
})
}
//
if (res.data.status) {
this.radioOptions.forEach(item => {
item.checked = item.value === res.data.status
})
}
}
})
},
/**
* 查所有可选属性
*/
selectAttribute() {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params: {
type: "wares_attribute"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allAttributeList = res.data
this.allAttributeNameList = res.data.map((item) => {
return item.label
})
}
})
},
/**
* 查所有可选子公司
*/
selectCompany() {
request({
url: '/admin-api/base/company/list',
method: 'get'
}).then((res) => {
console.log(res)
if (res.code == 200 && res.data.length > 0) {
this.allCompanyList = res.data
this.allCompanyList.map((item) => {
item.checked = false
})
}
})
},
/**
* 查所有可选来源
*/
selectDataFrom() {
request({
url: '/admin-api/system/dict-data/type',
method: 'get',
params: {
type: "wares_data_form"
}
}).then((res) => {
console.log(res)
if (res.code == 200) {
this.allFromList = res.data
this.allFromNameList = res.data.map((item) => {
return item.label
})
}
})
},
/**
* 选分类
*/
typePickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.typeIndex = e.detail.value
},
/**
* 选计量单位
*/
unitPickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.unitIndex = e.detail.value
},
/**
* 选来源
*/
fromPickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.fromIndex = e.detail.value
},
/**
* 选属性
*/
attributePickerChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.attributeIndex = e.detail.value
},
/**
* 新增/修改配件
*/
submit() {
//
if (!this.formData.name) {
uni.showToast({
title: '请输入配件名称!',
icon: 'none'
})
return
}
//
if (this.checkedCorpIdList.length > 0) {
this.formData.corpId = this.checkedCorpIdList.join()
}
//
this.formData.type = this.allTypeList[this.typeIndex].id
this.formData.unit = this.allUnitList[this.unitIndex].value
this.formData.dataForm = this.allFromList[this.fromIndex].value
this.formData.attribute = this.allAttributeList[this.attributeIndex].value
//
const isEdit = !!this.formData.id
const url = isEdit ? '/admin-api/repair/wares/update' : '/admin-api/repair/wares/create'
const method = isEdit ? 'put' : 'post'
const successMsg = isEdit ? '修改成功!' : '新增成功!'
request({
url: url,
method: method,
data: this.formData
}).then((res) => {
if (res.code == 200) {
uni.showToast({
title: successMsg,
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 700)
} else {
uni.showToast({
title: '操作失败,请联系管理员!',
icon: 'none'
})
}
})
}
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
.container { .container {
height: 100%; height: 100%;
background-color: #F3F5F7; background-color: #F3F5F7;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.listBox {
padding: 30 rpx 32 rpx;
flex: 1;
height: 0;
}
.list {
background-color: #fff;
padding: 0 30rpx;
height: 100%;
overflow: auto;
}
.formItem {
box-sizing: border-box;
margin: 0 auto;
padding: 30rpx;
display: flex; .listBox {
align-items: center; padding: 30 rpx 32 rpx;
justify-content: space-between; flex: 1;
column-gap: 20rpx; height: 0;
}
border-bottom: 1rpx solid #DDDDDD; .list {
} background-color: #fff;
.require::before{ padding: 0 30rpx;
content: "*"; height: 100%;
color: red; overflow: auto;
} }
.formLabel {
font-size: 32rpx;
color: #333333;
}
.formValue { .formItem {
flex: 1; box-sizing: border-box;
width: 0; margin: 0 auto;
text-align: right; padding: 30rpx;
font-size: 32rpx;
color: #999999;
}
.repairBottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.repairDesc { display: flex;
font-size: 28rpx; align-items: center;
color: #858BA0; justify-content: space-between;
} column-gap: 20rpx;
.repairUnit { border-bottom: 1rpx solid #DDDDDD;
color: #333333; }
}
.footer { .require::before {
padding: 14rpx 32rpx; content: "*";
background-color: #fff; color: red;
display: flex; }
align-items: center;
.repairNum { .formLabel {
flex: 1; font-size: 32rpx;
width: 0; color: #333333;
margin-right: 10rpx; }
}
.submit { .formValue {
width: 208rpx; flex: 1;
height: 72rpx; width: 0;
background: #0174F6; text-align: right;
border-radius: 38rpx 38rpx 38rpx 38rpx; font-size: 32rpx;
text-align: center; color: #999999;
line-height: 72rpx; }
font-size: 32rpx;
color: #FFFFFF; .repairBottom {
} display: flex;
} align-items: center;
</style> justify-content: space-between;
}
.repairDesc {
font-size: 28rpx;
color: #858BA0;
}
.repairUnit {
color: #333333;
}
.footer {
padding: 14rpx 32rpx;
background-color: #fff;
display: flex;
align-items: center;
.repairNum {
flex: 1;
width: 0;
margin-right: 10rpx;
}
.submit {
width: 208rpx;
height: 72rpx;
background: #0174F6;
border-radius: 38rpx 38rpx 38rpx 38rpx;
text-align: center;
line-height: 72rpx;
font-size: 32rpx;
color: #FFFFFF;
}
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff