Newer
Older
smartKitchenFront / src / views / order / orderShop.vue
liuyangyingjie on 26 Oct 2022 7 KB first commit
<template>
  <div class="order-container">
    <div class="order-from">
      <div class="order-title">下订单111</div>
      <div class="order-inputBox">
        <div class="input-item">
          <RedStar />
          <inputVue title="下单人" v-model="addInfo.userName" placeholder="请输入下单人姓名" class="inputWidth" width="380px" />
        </div>
        <div class="input-item">
          <RedStar />
          <inputVue title="联系方式" v-model="addInfo.userPhone" placeholder="请输入联系方式" class="inputWidth" width="380px" />
        </div>
      </div>
      <div class="order-inputBox">
        <div class="input-item">
          <RedStar />
          <inputVue title="签订日期" class="inputWidth">
            <el-date-picker v-model="addInfo.signDate" type="date" placeholder="选择日期" style="width: 380px;">
            </el-date-picker>
          </inputVue>
        </div>
        <div class="input-item">
          <RedStar />
          <inputVue title="交付日期" class="inputWidth">
            <el-date-picker v-model="addInfo.deliveryDate" type="date" placeholder="选择日期" style="width: 380px;">
            </el-date-picker>
          </inputVue>
        </div>
      </div>
      <div class="order-inputBox">
        <div class="input-item">
          <RedStar />
          <inputVue title="交付地址" class="inputWidth">
            <el-select v-model="addInfo.deliveryProvince" clearable placeholder="省/市"
              style="width:150px;margin-left: 55px;" @change="provinceChange($event)">
              <el-option v-for="item in form.provinceList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </inputVue>
          <inputVue title="" class="inputWidth">
            <el-select v-model="addInfo.deliveryCity" clearable placeholder="市/区" style="width:150px"
              @change="cityChange($event)">
              <el-option v-for="item in form.cityList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </inputVue>
          <inputVue title="" class="inputWidth">
            <el-select v-model="addInfo.deliveryArea" clearable placeholder="县/街道" style="width:150px">
              <el-option v-for="item in form.countyList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </inputVue>
          <inputVue v-model="addInfo.deliveryAddress" placeholder="请输入详细地址" class="inputWidth" width="440px" />
        </div>
      </div>
      <div class="order-inputBox">
        <div class="input-item">
          <RedStar />
          <inputVue title="收货人" v-model="addInfo.receiver" placeholder="请输入收货人姓名" class="inputWidth" width="380px" />
        </div>
        <div class="input-item">
          <RedStar />
          <inputVue title="收货人联系方式" v-model="addInfo.receiverPhone" placeholder="请输入联系方式" class="inputWidth"
            width="380px" />
        </div>
      </div>
      <div class="order-inputBox">
        <div class="input-item">
          <inputVue title="备注" class="inputWidth">
            <el-input type="textarea" :rows="4" placeholder="请输入备注" v-model="addInfo.remark" style="width: 380px;">
            </el-input>
          </inputVue>
        </div>
      </div>
    </div>
    <div class="order-list">
      <div class="title-box">
        <div class="list-title">产品列表</div>
        <div class="list-btn">
          <el-button @click="showAddDialogClick">添加采购需求</el-button>
        </div>
      </div>
      <div class="order-table">
        <el-table :data="addInfo.tableData.rows" border style="width: 100%;">
          <el-table-column type="index" label="序号" width="171px">
          </el-table-column>
          <el-table-column prop="brandName" label="产品品牌" width="300px">
          </el-table-column>
          <el-table-column prop="categoryStr" label="产品品类" width="300px">
          </el-table-column>
          <el-table-column prop="productCode" label="产品型号" width="300px">
          </el-table-column>
          <el-table-column prop="address" label="产品数量" width="300px">
          </el-table-column>
          <el-table-column prop="address" label="产品单价" width="300px">
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="btnBox">
      <el-button type="primary" class="save" @click="save">保存</el-button>
      <el-button type="info" class="close">取消</el-button>
    </div>
    <orderAddDialog v-if="isShowAdd" @close="close" />
  </div>
</template>

<script>
import RedStar from '../../components/mycomponent/redStar.vue'
import inputVue from '../../components/mycomponent/input/inputVue.vue'
import orderAddDialog from '../../components/mycomponent/dialog/orderAddDialog.vue'

import { add, order_area } from '../../api/order/order'
export default {
  components: {
    RedStar, inputVue, orderAddDialog
  },
  data () {
    return {
      isShowAdd: false,//添加采购需求
      options: {},
      addInfo: {
        userName: '',//下单人
        userPhone: '',//联系方式
        signDate: '',//签订日期
        deliveryDate: '',//交付日期
        deliveryProvince: '',//地址-省
        deliveryCity: '',//地址-市
        deliveryArea: '',//地址-区
        deliveryAddress: '',//详细地址
        receiver: '',//收货人
        receiverPhone: '',//收货人联系方式
        remark: '',//备注
        tableData: [],
      },
      form: {
        provinceList: [],
        cityList: [],
        countyList: []
      },
      CITY: [],
      XIAN: []
    }
  },
  mounted () {
    order_area('pid=0', {}).then(res => {
      console.log(res, 'Sheng')
      this.form.provinceList = res
    })
  },
  methods: {
    save () {
      add(this.addInfo).then(res => {
        console.log(res)
      })
      this.addInfo = ''
    },
    provinceChange (that) {
      console.log(that)
      order_area(`pid=${that}`, {}).then(res => {
        console.log(res, 'Shi')
        this.form.cityList = res
      })
    },
    cityChange (that) {
      console.log(that)
      order_area(`pid=${that}`, {}).then(res => {
        console.log(res, 'Xian')
        this.form.countyList = res
      })
    },
    showAddDialogClick () {
      this.isShowAdd = true
    },
    close () {
      this.isShowAdd = false
    }
  },
  watch: {
    addInfo: {
      handler (newval, oldval) {
        console.log(newval, oldval)
        if (!this.addInfo.deliveryProvince) {
          this.addInfo.deliveryCity = ''
          this.addInfo.deliveryArea = ''
        } else if (!this.addInfo.deliveryCity) {
          this.addInfo.deliveryArea = ''
        }
      },
      deep: true,
      immediate: true
    }
  }
}
</script>

<style lang='scss' scoped>
.order-container {
  .order-from {
    .order-title {
      height: 60px;
      line-height: 40px;
      position: relative;
      padding: 10px 0 10px 20px;
      font-weight: bold;
      color: white;
      background-color: #28739e;
      font-size: 16px;
    }

    .order-inputBox {
      display: flex;
      margin-left: 20px;

      .input-item {
        display: flex;
        width: 540px;
        align-items: center;
        justify-content: space-between;
      }
    }
  }

  .order-list {
    .title-box {
      margin-top: 20px;
      font-size: 16px;
      font-weight: bold;
      color: white;
      padding: 10px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background-color: #28739e;
    }

    .order-table {
      margin-top: 20px;
    }
  }

  .btnBox {
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-evenly;

    .save,
    .close {
      width: 100px;
    }

  }
}
</style>