123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- <template>
- <view class="price">
- <view class="picker-btn">
- <view class="btn">
- <button class="oper-btn" type="primary" @click="showPicker=true">
- {{$t('approval.information')}}
- </button>
- </view>
- <view class="btn">
- <button class="oper-btn" type="primary" @click="sureChangePrice">
- {{$t('approval.confirmPrice')}}
- </button>
- </view>
-
- </view>
- <u-sticky bgColor="#fff">
- <view class="change-price-title">
- <view class="change-price-item">
- {{$t('approval.adjustmentRange')}}:
- <view class="inp">
- <u-input type="number" v-model="changePrice" />
- </view>
- <view class="btn">
- <button class="oper-btn" type="primary" @click="priceChange(true)">{{$t('approval.adjust')}}</button>
- </view>
- </view>
- <view class="change-price-item">
- {{$t('approval.fixed')}}:
- <view class="inp">
- <u-input type="number" v-model="fixPrice" />
- </view>
- <view class="btn">
- <button class="oper-btn" type="primary" @click="priceChange(false)">{{$t('approval.adjust')}}</button>
- </view>
- </view>
- </view>
- </u-sticky>
- <template v-if="details.length">
- <view class="details-wrap">
- <p class="details-line details-title">
- <span v-if="priceType=='101'">{{$t('order.companyName')}}</span>
- <span v-if="priceType=='102'">{{$t('order.region')}}</span>
- <span>{{$t('order.materialName')}}</span>
- <span>{{$t('approval.latestPrice')}}</span>
- <span>{{$t('approval.adjustedPrice')}}</span>
- </p>
- <p v-for="(item,index) in details" :key="index" class="details-line">
- <span v-if="priceType=='101'">{{item.companyName}}</span>
- <span v-if="priceType=='102'">{{item.blockName}}</span>
- <span>{{item.materialName}}</span>
- <span>{{item.lastPrice || 0}}</span>
- <span>
- <u-input type="number" v-model="item.price" />
- </span>
- </p>
- </view>
-
- </template>
- <template v-else>
- <u-empty mode="list" text='请先选择调价信息' icon="https://cdn.uviewui.com/uview/empty/list.png">
- </u-empty>
- </template>
- <u-popup :show="showPicker" mode="center" zIndex="998" :overlay="false" @close="showView = false" >
- <view class="picker-card">
- <!-- 选择客户 -->
- <view class="choose-wrap">
- <view v-if="priceType == '101'" class="item">
- <view class="search-wrap">
- {{$t('approval.customerSelection')}}:
- </view>
- <view class="search-wrap">
- <u-input v-model="keyword" @change="getOptions" :placeholder="$t('base.search.keySearch')"/>
- </view>
- <u-checkbox-group
- v-model="clientIds"
- placement="column"
- >
- <u-checkbox
- :customStyle="{marginBottom: '8px'}"
- v-for="(item, index) in companyList"
- :key="index"
- :label="item.name"
- :name="item.id"
- >
- </u-checkbox>
- </u-checkbox-group>
- </view>
- <!-- 选择区域 -->
- <view v-if="priceType == '102'" class="item">
- <view class="search-wrap">
- {{$t('approval.regionalSelection')}}:
- </view>
- <view class="search-wrap">
- <u-input v-model="keyword" @change="getOptions" :placeholder="$t('base.search.keySearch')"/>
- </view>
- <u-checkbox-group
- v-model="blockIds"
- placement="column"
- >
- <u-checkbox
- :customStyle="{marginBottom: '8px'}"
- v-for="(item, index) in blockList"
- :key="index"
- :label="item.name"
- :name="item.id"
- >
- </u-checkbox>
- </u-checkbox-group>
- </view>
- <!-- 选择产品 -->
- <view class="item">
- <view class="search-wrap">
- {{$t('approval.productSelection')}}:
- </view>
- <view class="search-wrap">
- <u-input v-model="proKeyword" @change="getMater" :placeholder="$t('base.search.keySearch')"/>
- </view>
- <u-checkbox-group
- v-model="productIds"
- placement="column"
- >
- <u-checkbox
- :customStyle="{marginBottom: '8px'}"
- v-for="(item, index) in meterList"
- :key="index"
- :label="item.name"
- :name="item.id"
- >
- </u-checkbox>
- </u-checkbox-group>
- </view>
- </view>
- <view class="card-oper">
- <view class="btn">
- <button @click="showPicker = false">{{$t('settings.cancelText')}}</button>
- </view>
- <view class="btn">
- <button type='primary' @click="getPriceDetails">{{$t('settings.confirmText')}}</button>
- </view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import {
- priceDetails
- } from "../../api/approval"
- import {
- getMater,
- getCompany,
- getBlock,
- } from "../../api/tenantorder"
- export default {
- data(){
- return {
- fixPrice:'',
- changePrice:null,
- showPicker:false,
- priceType:null,
- meterList:[], //产品选项列表
- companyList:[], //客户选项列表
- blockList:[], //区域选项列表
- details:[],
- keyword:'',
- proKeyword:'',
- clientIds:[], //选择的客户id
- blockIds:[], //选择的区域id
- productIds:[], //选择的产品
- }
- },
- onLoad(options) {
- this.priceType = options.priceType
- this.getMater()
- this.getOptions()
- },
- methods:{
- //确认调价
- sureChangePrice(){
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2]; //上一个页面
- let details=[]
- this.details.forEach(item=>{
- if(this.priceType == '101'){
- details.push({
- companyId: item.companyId,
- companyName: item.companyName,
- lastPrice: item.lastPrice,
- price: item.price,
- materialId: item.materialId,
- materialName: item.materialName,
- })
- }else if(this.priceType == '102'){
- details.push({
- blockId: item.blockId,
- blockName: item.blockName,
- lastPrice: item.lastPrice,
- price: item.price,
- materialId: item.materialId,
- materialName: item.materialName,
- })
- }
-
- })
- prevPage.$vm.form.details = details;
- uni.navigateBack();
- },
- //获取客户/区域选项
- getOptions(){
- if(this.priceType == '101'){
- getCompany({type:'102'},this.keyword).then(res=>{
- if(res.data.code == 0){
- this.companyList = res.data.data
- }
- })
- }
- if(this.priceType == '102'){
- getBlock(this.keyword).then(res=>{
- if(res.data.code == 0){
- this.blockList = res.data.data
- }
- })
- }
- },
- //获取产品选项
- getMater(){
- getMater({type:"101"},this.proKeyword).then(res=>{
- if(res.data.code == 0){
- this.meterList=res.data.data
- }
- })
- },
- //调整价格
- priceChange(boo){
- if(boo){
- this.details.forEach(item=>{
- if(item.lastPrice){
- item.price = Number(item.lastPrice) + Number(this.changePrice)
- }else{
- item.price = Number(this.changePrice)
- }
- })
- }else{
- this.details.forEach(item=>{
- item.price = Number(this.fixPrice)
- })
- }
- },
- //获取产品价格详细
- getPriceDetails(){
- let data={}
- if(this.priceType == '101'){
- if(this.clientIds.length && this.productIds.length){
- data={
- companyIds:this.clientIds,
- materialIds:this.productIds,
- priceType:this.priceType,
- }
- priceDetails(data).then(res=>{
- if(res.data.code == 0){
- this.details = res.data.data
- this.showPicker = false
- }
- })
- }
- }else if(this.priceType == '102'){
- if(this.blockIds.length && this.productIds.length){
- data={
- blockIds:this.blockIds,
- materialIds:this.productIds,
- priceType:this.priceType,
- }
- priceDetails(data).then(res=>{
- if(res.data.code == 0){
- this.details = res.data.data
- this.showPicker = false
- }
- })
- }
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /* #ifndef APP-NVUE */
- view {
- display: flex;
- box-sizing: border-box;
- flex-direction: column;
- }
- page {
- background-color: #f8f8f8;
- }
- /* #endif*/
- .price{
- /* #ifndef APP-NVUE */
- display: flex;
- width: 750rpx;
- min-height: 100vh;
- /* #endif */
- flex-direction: column;
- flex: 1;
- background-color: #f8f8f8;
- padding-bottom: 160rpx;
- .change-price-title{
- background-color: #fff;
- padding: 24rpx 32rpx;
- width: 100%;
- display: flex;
- .change-price-item{
- display: flex;
- flex-direction: row;
- align-items: center;
- margin-bottom: 24rpx;
- .btn{
- width: 20%;
- margin-left: 16rpx;
- .oper-btn{
- margin: 0;
- border-radius: 10rpx;
- }
- }
- .inp{
- margin-left: 16rpx;
- flex: 1;
- }
- }
- }
-
- .details-wrap{
- padding: 32rpx;
- background: #fff;
- margin-top: 24rpx;
- .details-line{
- display: flex;
- flex-direction: row;
- line-height: 40px;
- span{
- width: 25%;
- font-size: 28rpx;
- text-align: center;
- }
- }
- .details-title{
- span{
- font-weight: bold;
- }
- }
- .details-line:nth-child(odd){
- background-color: #f2f2f2;
- }
- .details-line:nth-child(even){
- background-color: #fff;
- }
- }
-
- .picker-btn{
- padding: 32rpx;
- position: fixed;
- bottom: 0;
- width: 100%;
- flex-direction: row;
- justify-content: space-between;
- background-color: #fff;
- z-index: 2;
- .btn{
- width: 48%;
- .oper-btn{
- margin: 0;
- }
- }
- }
- // padding: 32rpx;
- .picker-card{
- padding: 32rpx 32rpx 144rpx;
- position: relative;
- height: 100%;
- overflow-y: scroll;
- .choose-wrap{
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- height: 100%;
- .item{
- width: 45%;
- height: 100%;
- overflow-y: scroll;
- .search-wrap{
- margin-bottom: 24rpx;
- }
- }
- }
- .card-oper{
- position: absolute;
- width: 100%;
- bottom: 0;
- left:0;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 24rpx;
- .btn{
- width: 45%;
- .oper-btn{
- margin: 0;
- }
- }
- }
- }
- }
- /deep/ .u-popup__content{
- height: 70%;
- overflow-y: scroll;
- width: 90%;
- border-radius: 6px;
- }
- </style>
|