yangan
2024-05-30 26cf5599ccc92203cb7313385c2bf3c26c42ac0c
pages/customer-page/addDailyPlan/addDailyPlan.vue
@@ -6,38 +6,13 @@
         <view class="product-info_block">
            <view class="selected-info">
               <view class="selected-info_label">
                  当前选择单位
                  当前选择订单
               </view>
               <view class="selected-info_text">
                  <niceui-data-select-input v-model="deptId"
                     :localdata="deptList"
                     placeholder="请选择单位"
                     :localdata="customerNameList"
                     placeholder="请选择订单"
                     @change="deptChange"></niceui-data-select-input>
               </view>
            </view>
            <view class="selected-info">
               <view class="selected-info_label">
                  当前选择产品
               </view>
               <view class="selected-info_text">
                  <niceui-data-select-input v-model="productName"
                     :localdata="productNameList"
                     label="产品选择"
                     placeholder="请选择产品"
                     @change="productNameChange"></niceui-data-select-input>
               </view>
            </view>
            <view class="selected-info">
               <view class="selected-info_label">
                  当前选择煤场
               </view>
               <view class="selected-info_text">
                  <niceui-data-select-input v-model="filedId"
                     :localdata="filedNameList"
                     label="煤场选择"
                     placeholder="请选择煤场"
                     @change="filedChange"></niceui-data-select-input>
               </view>
            </view>
         </view>
@@ -57,18 +32,37 @@
         <!-- 客户名称 -->
         <view class="customer-name">
            <view class="customer-name_label">
               选择客户
               车数
            </view>
            <view class="customer-name_block"
               @click="selfDeliver">
               <input class="customer-name_block-input"
                  type="text"
                  placeholder="请选择客户"
                  v-model="customerName"
                  @focus="selfDeliver"
                  ref="selectCustomer" />
            <view class="customer-name_block">
                    <u--input
                     class="customer-name_block-input"
                     placeholder="请输入车数"
                     border="surround"
                     v-model="value"
                  ></u--input>
            </view>
         </view>
             <view class="table">
         <uni-table border stripe
         emptyText="暂无更多数据">
               <uni-tr>
                   <uni-th align="center">产品名称</uni-th>
                  <uni-th align="center">类型</uni-th>
                   <uni-th align="center">仓库</uni-th>
               </uni-tr>
               <uni-tr v-for="(item, index) in subDataList" :key="index">
                  <uni-td align="center">
                     <view>{{ item.productName }}</view></uni-td>
               <uni-td>
                  <view class="name">{{ item.orderType }}</view>
               </uni-td>
                <uni-td align="center">
               <view>{{ item.bunkerName }}</view></uni-td>
            </uni-tr>
            </uni-table>
       </view>
      </view>
      <!-- 提交 -->
      <view class="confirm-build">
@@ -79,7 +73,8 @@
               :disabled="abledBuild"></u-button>
         </view>
      </view>
      <view class="">
      <!-- <view class="">
         <u-popup :closeable='true'
            :round="30"
            mode='bottom'
@@ -112,7 +107,8 @@
               </view>
            </view>
         </u-popup>
      </view>
      </view> -->
   </view>
</template>
@@ -124,11 +120,11 @@
         NiceUIDataSelectInput
      },
      onLoad() {
         this.getCarNoByVarieties()
         // this.getCarNoByVarieties()
            this.getDingdan();
         if (this.deptId && this.productName) {
            this.getShipToList()
         }
         // if (this.deptId && this.productName) {
         //    this.getShipToList()
         // }
         this.sendDate = this.sendDateStart = dayjs().format('YYYY-MM-DD')
         this.sendDateEnd = dayjs().add(7, 'day').format('YYYY-MM-DD')
      },
@@ -147,145 +143,48 @@
            sendDateStart: '',
            sendDateEnd: '',
            customerId: '',
            value:'',
            customerName: '',
            customerNameList: [],
            buildLoading: false
            buildLoading: false,
            subDataList:[],
         }
      },
      computed: {
         abledBuild() {
            return !this.filedId || !this.deptId || !this.productName || !this.customerId
            return !this.subDataList.length || !this.sendDate || !this.value
         }
      },
      methods: {
         // 获取客户
         getShipToList() {
            uni.showLoading({
               title: "加载中"
            })
            this.$reqGet('getDeptAndProductNameByCustomer', { deptId: this.deptId, productName: this.productName })
               .then(res => {
                  uni.hideLoading()
                  if (res.code == 0) {
                     this.customerNameList = res.data
                  }
               })
         },
            //查询订单
            getDingdan(){
                    this.$reqGet('getOrderList')
                    this.$reqGet('getAppOrderList',{orderType:'外购'})
               .then(res => {
                  uni.hideLoading()
                  if (res.code == 0) {
                     this.customerNameList = res.data
                     this.customerNameList = res.data.map(item=>{
                        item.text = item.productName + '-' + item.orderCode;
                        item.value = item.id;
                        return item;
                     })
                     console.log(this.customerNameList,'')
                  }
               })
            },
         //查询相关单位
         getCarNoByVarieties() {
            uni.showLoading({
               title: "加载中"
            })
            this.$reqGet('getCarNoByVarieties').then(res => {
               uni.hideLoading()
               if (res.code == 0) {
                  this.deptList = res.data.map(v => {
                     return {
                        value: v.deptId,
                        text: v.deptName
                     }
                  })
                  this.deptId = Array.isArray(this.deptList) && this.deptList.length !== 0 ? this.deptList[0]
                     .value : ''
               } else {
                  this.$u.toast('加载失败')
               }
            }).then(() => {
               this.getDeptByProductName()
               this.getDeptIdByFiledList()
            })
         },
         deptChange(e) {
            this.deptName = this.deptList.find(v => v.value === e).text
            this.getDeptByProductName()
            this.getDeptIdByFiledList()
            if (this.deptId && this.productName) {
               this.getShipToList()
            }
         },
         // 根据部门获取产品名称
         getDeptByProductName() {
            this.$reqGet('getDeptByProductName', { deptId: this.deptId }).then(res => {
               this.productNameList = res.data.map(v => {
                  return {
                     value: v.productName,
                     text: v.productName
                  }
               })
               this.productName = Array.isArray(this.productNameList) && this.productNameList.lenght !== 0 ?
                  this.productNameList[0].value : ''
            }).then(() => {
               this.getShipToList()
            })
         },
         // 根据部门获取煤场名称
         getDeptIdByFiledList() {
            this.$reqGet('getDeptIdByFiledList', { deptId: this.deptId }).then(res => {
               this.filedNameList = res.data.map(v => {
                  return {
                     value: v.id,
                     text: v.name
                  }
               })
               if (Array.isArray(this.filedNameList) && this.filedNameList.length === 1) {
                  this.filedId = this.filedNameList[0].value
                  this.filedName = this.filedNameList[0].text
               } else if (Array.isArray(this.filedNameList) && this.filedNameList.length > 1) {
                  this.filedId = ''
                  this.filedName = ''
               }
            })
         },
         filedChange(e) {
            this.filedName = this.filedNameList.find(v => v.value === e).text
         },
         productNameChange(e) {
            if (this.deptId && this.productName) {
               this.getShipToList()
            }
         },
         selfDeliver() {
            this.selfDeliverShow = true
         },
         selfDeliverClose() {
            this.selfDeliverShow = false
         },
         selfDeliverOpen() {
            this.selfDeliverShow = true
         },
         selectCustomer(value) {
            this.customerId = value.customerId
            this.customerName = value.customerName
            this.selfDeliverShow = false
            console.log(e,'eee');
            this.subDataList = this.customerNameList.filter(item=>item.id === e);
         },
         confirmBuild() {
            let form = {
               carNo: uni.getStorageSync('carNo'),
               coalName: this.productName,
               deptId: this.deptId,  //部门Id
               deptName: this.deptName,  //部门名称
               filedId: this.filedId,  //煤场Id
               filedName: this.filedName,  //煤场名称
               orderType: "外购",
               sendDate: this.sendDate,  //发运时间
               xsUserId1: uni.getStorageSync('userId'),  //用户id
               isPretendDischar: 1,  //是否能装卸 1已经确认装卸 0不需要装卸
               isSpecial: 1,  //是否是特产品 1特殊产品 0不是特使产品
               customerId: this.customerId,
               customerName: this.customerName
              orderId:this.deptId,
              carNum:this.value,
              sendDate:this.sendDate,
              sendSign:0,
            }
            this.buildLoading = true
            this.$reqPost('saveDeliveryNote', form, 'json').then(res => {
            this.$reqPost('addDeliveryPlan', form, 'json').then(res => {
               this.buildLoading = false
               if (res.code == 0) {
                  this.$u.toast('创建成功')
@@ -307,6 +206,13 @@
<style lang="scss"
   scoped>
   .table{
      width: 94%;
      margin-left: 20rpx;
   /deep/ .uni-table{
         min-width: 340rpx!important;
      }
   }
   /deep/.u-button {
      width: 100%;
      height: 36px !important;
@@ -334,10 +240,8 @@
      .product-info {
         width: 96%;
         height: vww(250);
         margin: vww(8);
         margin-top: vww(20);
         box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
         border-radius: 20rpx;
         position: relative;
         @include flex;
@@ -345,7 +249,6 @@
         &_block {
            width: 88%;
            height: vww(200);
            margin-left: vww(10);
            @include flex;
            flex-direction: column;
@@ -416,7 +319,7 @@
      .confirm-build {
         width: 100%;
         height: vww(80);
         height: vww(60);
         background-color: #ffffff;
         position: fixed;
         bottom: 0;