| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view class="app-content">
- <view v-if="!$util.isEmpty(list.data)" style="padding-bottom:120upx;">
- <t-table :headerBackgroundColor="'#F0F2F6'">
- <t-tr header>
- <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.inTurn" @focus="item.inTurn=''" name="inTurn" type="number" style="border:1upx solid #cccccc;" /></view>
- </t-td>
- <t-td align="center" color="info">
- <view><input v-model="item.shelfLife" @focus="item.shelfLife=''" name="shelfLife" type="digit" style="border:1upx 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:20upx;" class="admin-button-com middle blue" @click="showBatchUpdate('update')">整列改为</view>
- <view style="margin-left:20upx;" class="admin-button-com middle blue" @click="savePrice">全部保存</view>
- </view>
- <modal-module :show="batchModel" @click="affirmBatch" title="批量操作" color="#333" :size="32" padding="30upx 30upx" >
- <template slot="customContent">
- <view class="select-cmd_bx">
- <view class="num_bx" style="margin:60upx 0 60upx 0;font-size:35upx;">
- <view class="flex">数值:<input v-model="batchNum" type="digit" style="border:1upx solid #CCCCCC;height:60upx;" /></view>
- </view>
- </view>
- </template>
- </modal-module>
- </view>
- </template>
- <script>
- import AppWrapperEmpty from "@/components/app-wrapper-empty";
- import { productList,batchChangeMore } from '@/api/product'
- import list from '@/mixins/list'
- import ModalModule from "@/components/plugin/modal";
- export default {
- name: "more",
- components: {
- AppWrapperEmpty,ModalModule
- },
- mixins:[list],
- data() {
- return {
- batchModel:false,
- batchStyle:'add',
- batchNum:'',
- 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.batchNum = ''
- this.batchModel = false;
- } else {
- if(this.$util.isMoney(this.batchNum) == false){
- this.$msg('请填写数值')
- return false
- }
- let currentNum = Number(this.batchNum)
- this.list.data.forEach(function(value,index,array){
- if(that.batchStyle =='add'){
- if(that.levelIndex == 1){
- array[index].inTurn = parseFloat((Number(array[index].inTurn) + currentNum).toFixed(2))
- }else if(that.levelIndex == 2){
- array[index].shelfLife = parseFloat((Number(array[index].shelfLife) + currentNum).toFixed(2))
- }else{
- }
- }else{
- if(that.levelIndex == 1){
- array[index].inTurn = parseFloat((currentNum).toFixed(2))
- }else if(that.levelIndex == 2){
- array[index].shelfLife = parseFloat((currentNum).toFixed(2))
- }else{
- }
- }
- });
- this.batchNum = ''
- 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.inTurn) == false){
- that.$msg('【'+value.name+'】的排序值填写错误')
- return false
- }
- if(that.$util.isMoney(value.shelfLife) == false){
- that.$msg('【'+value.name+'】的保持期填写错误')
- return false
- }
- addData.push({id:value.id,inTurn:value.inTurn,shelfLife:value.shelfLife})
- })
- let addString = JSON.stringify(addData)
- batchChangeMore({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>
|