|
|
@@ -0,0 +1,191 @@
|
|
|
+<template>
|
|
|
+ <view>
|
|
|
+ <view v-if="!$util.isEmpty(list.data)" style="padding-bottom:120rpx;">
|
|
|
+ <t-table :headerBackgroundColor="'#F0F2F6'">
|
|
|
+ <t-tr header>
|
|
|
+ <t-th>名称</t-th>
|
|
|
+ <t-th>散客</t-th>
|
|
|
+ <t-th>普店</t-th>
|
|
|
+ <t-th>银店</t-th>
|
|
|
+ <t-th>金店</t-th>
|
|
|
+ </t-tr>
|
|
|
+ <view v-for="(item, index) in list.data" :key="index">
|
|
|
+ <t-tr>
|
|
|
+ <t-td align="center" color="info"><view>{{item.name}}</view></t-td>
|
|
|
+ <t-td align="center" color="info">
|
|
|
+ <view><input v-model="item.skAddPrice" name="skAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
|
|
|
+ </t-td>
|
|
|
+ <t-td align="center" color="info">
|
|
|
+ <view><input v-model="item.addPrice" name="price" type="digit" style="border:1rpx solid #cccccc;" /></view>
|
|
|
+ </t-td>
|
|
|
+ <t-td align="center" color="info">
|
|
|
+ <view><input v-model="item.hjAddPrice" name="hjAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
|
|
|
+ </t-td>
|
|
|
+ <t-td align="center" color="info">
|
|
|
+ <view><input v-model="item.zsAddPrice" name="zsAddPrice" type="digit" style="border:1rpx solid #cccccc;" /></view>
|
|
|
+ </t-td>
|
|
|
+ </t-tr>
|
|
|
+ </view>
|
|
|
+ </t-table>
|
|
|
+ </view>
|
|
|
+ <view v-else>
|
|
|
+ <AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
|
|
|
+ </view>
|
|
|
+ <view class="app-footer">
|
|
|
+ <view class="admin-button-com middle blue" @click="showBatchUpdate('add')">整列累加</view>
|
|
|
+ <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="showBatchUpdate('update')">整列改为</view>
|
|
|
+ <view style="margin-left:30rpx;" class="admin-button-com middle blue" @click="savePrice">全部保存</view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <modal-module :show="batchModel" @cancel="modalCancel" @click="affirmBatch" title="批量操作" color="#333" :size="32" padding="30rpx 30rpx" >
|
|
|
+ <template slot="customContent">
|
|
|
+ <view class="select-cmd_bx">
|
|
|
+ <view class="num_bx" style="margin:60rpx 0 60rpx 0;font-size:35rpx;">
|
|
|
+ <view class="flex">金额:<input v-model="batchPrice" type="digit" focus style="border:1rpx solid #CCCCCC;height:60rpx;" /></view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </modal-module>
|
|
|
+
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import AppWrapperEmpty from "@/components/app-wrapper-empty";
|
|
|
+import { productList,batchChangeAddPrice } from '@/api/product'
|
|
|
+import list from '@/mixins/list'
|
|
|
+import ModalModule from "@/components/plugin/modal";
|
|
|
+export default {
|
|
|
+ name: "addPrice",
|
|
|
+ components: {
|
|
|
+ AppWrapperEmpty,ModalModule
|
|
|
+ },
|
|
|
+ mixins:[list],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ batchModel:false,
|
|
|
+ batchStyle:'add',
|
|
|
+ batchPrice:'',
|
|
|
+ focusOn:false,
|
|
|
+ levelIndex:0
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ showBatchUpdate(styleInfo){
|
|
|
+ if (this.$util.isEmpty(this.list.data)){
|
|
|
+ this.$msg('没有花材')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ this.batchStyle = styleInfo
|
|
|
+ let self = this
|
|
|
+ let levelList = ['请选择列:','散客', '普店', '银店', '金店']
|
|
|
+ uni.showActionSheet({
|
|
|
+ itemList: levelList,
|
|
|
+ success: function (respond) {
|
|
|
+ self.levelIndex = respond.tapIndex
|
|
|
+ self.batchModel = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ affirmBatch(val) {
|
|
|
+ let that = this
|
|
|
+ if (val.index === 0) {
|
|
|
+ this.batchPrice = ''
|
|
|
+ this.batchModel = false;
|
|
|
+ } else {
|
|
|
+ if(this.$util.isMoney(this.batchPrice) == false){
|
|
|
+ this.$msg('请填写金额')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let currentPrice = Number(this.batchPrice)
|
|
|
+ this.list.data.forEach(function(value,index,array){
|
|
|
+ if(that.batchStyle =='add'){
|
|
|
+ if(that.levelIndex == 1){
|
|
|
+ array[index].skAddPrice = parseFloat((Number(array[index].skAddPrice) + currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 2){
|
|
|
+ array[index].addPrice = parseFloat((Number(array[index].addPrice) + currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 3){
|
|
|
+ array[index].hjAddPrice = parseFloat((Number(array[index].hjAddPrice) + currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 4){
|
|
|
+ array[index].zsAddPrice = parseFloat((Number(array[index].zsAddPrice) + currentPrice).toFixed(2))
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(that.levelIndex == 1){
|
|
|
+ array[index].skAddPrice = parseFloat((currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 2){
|
|
|
+ array[index].addPrice = parseFloat((currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 3){
|
|
|
+ array[index].hjAddPrice = parseFloat((currentPrice).toFixed(2))
|
|
|
+ }else if(that.levelIndex == 4){
|
|
|
+ array[index].zsAddPrice = parseFloat((currentPrice).toFixed(2))
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.batchPrice = ''
|
|
|
+ this.batchModel = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ savePrice(){
|
|
|
+ let that = this
|
|
|
+ let addData = [];
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ this.list.data.forEach(function(value,index,array){
|
|
|
+
|
|
|
+ if(that.$util.isMoney(value.skAddPrice) == false){
|
|
|
+ that.$msg('【'+value.name+'】的散客加价填写错误')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(that.$util.isMoney(value.addPrice) == false){
|
|
|
+ that.$msg('【'+value.name+'】的普店加价填写错误')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(that.$util.isMoney(value.hjAddPrice) == false){
|
|
|
+ that.$msg('【'+value.name+'】的银店加价填写错误')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(that.$util.isMoney(value.zsAddPrice) == false){
|
|
|
+ that.$msg('【'+value.name+'】的金店加价填写错误')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ addData.push({id:value.id,skAddPrice:value.skAddPrice,addPrice:value.addPrice,hjAddPrice:value.hjAddPrice,zsAddPrice:value.zsAddPrice})
|
|
|
+ })
|
|
|
+ let addString = JSON.stringify(addData)
|
|
|
+ batchChangeAddPrice({addData:addString}).then(res=>{
|
|
|
+ uni.hideLoading()
|
|
|
+ if(res.code == 1){
|
|
|
+ setTimeout(function(){
|
|
|
+ that.$msg(res.msg)
|
|
|
+ },500)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async init(){
|
|
|
+ const res = await productList({
|
|
|
+ page:this.list.page,showPage:1,pageSize:2000,classId:this.option.classId
|
|
|
+ })
|
|
|
+ this.completes(res)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onPullDownRefresh() {
|
|
|
+ this.resetList();
|
|
|
+ await this.init()
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
+ },
|
|
|
+ async onReachBottom() {
|
|
|
+ if (!this.list.finished) {
|
|
|
+ await this.init()
|
|
|
+ uni.stopPullDownRefresh();;
|
|
|
+ } else {
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|