Vue+ElementUI项目笔记(六、查询)

模板

    <template>
 <div class="Search">
  <el-form :model="searchInfo" class="demo-form-inline search_form" label-position="top" ref="searchForm">
<el-row :gutter="10">
  <el-col :span="4">
    <el-form-item label="运单号" class="grid-content break_line">
      <el-col :span="9">
        <el-form-item prop="params.order_three_code">
          <el-input size="mini" v-model="searchInfo.params.order_three_code" placeholder="三字码"></el-input>
        </el-form-item>
      </el-col>
      <el-col class="line" :span="1">-</el-col>
      <el-col :span="14">
        <el-form-item prop="params.order_num">
          <el-input size="mini" v-model="searchInfo.params.order_num" placeholder="八位数字"></el-input>
        </el-form-item>
      </el-col>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="单据类型" class="grid-content" prop="params.receipt_type">
      <el-select size="mini" v-model="searchInfo.params.receipt_type" placeholder="">
        <el-option label="全部" value=""></el-option>
        <el-option label="及时" value="0"></el-option>
        <el-option label="事后" value="1"></el-option>
      </el-select>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="制单类型" class="grid-content" prop="params.easy_flag">
      <el-select size="mini" v-model="searchInfo.params.easy_flag" placeholder="">
        <el-option label="全部" value=""></el-option>
        <el-option label="正常制单" value="0"></el-option>
        <el-option label="简易制单" value="1"></el-option>
      </el-select>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="出港状态" class="grid-content" prop="params.departure_status">
      <el-select size="mini" v-model="searchInfo.params.departure_status" placeholder="">
        <el-option label="全部" value=""></el-option>
        <el-option label="未出港" value="0"></el-option>
        <el-option label="部分出港" value="1"></el-option>
        <el-option label="已出港" value="2"></el-option>
      </el-select>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="始发站" class="grid-content" prop="params.departure">
      <el-input size="mini" v-model="searchInfo.params.departure" placeholder="始发站代码"></el-input>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="目的站" class="grid-content" prop="params.destination">
      <el-input size="mini" v-model="searchInfo.params.destination" placeholder="目的站代码"></el-input>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="发货人" class="grid-content" prop="params.sender">
      <el-input size="mini" v-model="searchInfo.params.sender" placeholder="发货人代码"></el-input>
    </el-form-item>
  </el-col>
  <el-col :span="4">
    <el-form-item label="收货人" class="grid-content" prop="params.receiver">
      <el-input size="mini" v-model="searchInfo.params.receiver" placeholder="收货人代码"></el-input>
    </el-form-item>
  </el-col>
  <el-col :span="8">
    <el-form-item label="开票日期" class="grid-content" prop="timeValue">
      <el-date-picker
        size="mini"
        v-model="searchInfo.timeValue"
        type="datetimerange"
        :picker-options="pickerOptions"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        align="right"
        value-format="yyyy-MM-dd HH:mm:ss"
        style="width:100%;"
      >
      </el-date-picker>
    </el-form-item>
  </el-col>
</el-row>
 </el-form>
   <div class="btn_wrap">
<el-row>
  <el-col :span="6" :offset="18">
  <div class="grid-content bg-purple">
    <el-button type="primary" icon="el-icon-search" size="mini" @click="search">查询</el-button>
    <el-button type="primary" icon="el-icon-plus" size="mini" @click="add">添加</el-button>
    <el-button type="primary" icon="el-icon-refresh" size="mini" @click="reset">重置</el-button>
  </div>
  </el-col>
</el-row>
 </div>
   <div class="receive_list">
<el-table :data="tableData" border style="width: 100%" height="370" size="small" :row-class-name="tableRowClassName">
  <el-table-column fixed type="index" :index="indexMethod" label="序号"></el-table-column>
  <el-table-column fixed label="操作">
    <template slot-scope="scope">
      <el-tooltip class="item" effect="dark" content="编辑" placement="left">
        <el-button type="primary" icon="el-icon-edit" size="mini" @click="edit(scope.row)"></el-button>
      </el-tooltip>
    </template>
  </el-table-column>
  <el-table-column prop="order_no" label="运单号" width="100">></el-table-column>
  <el-table-column prop="departure" label="始发站" width="100"></el-table-column>
  <el-table-column prop="destination" label="目的站" width="100"></el-table-column>
  <el-table-column prop="state" label="单号状态" :formatter="stateFormat"></el-table-column>
  <el-table-column prop="sender_name" label="发货人名称" width="150"></el-table-column>
  <el-table-column prop="receiver_name" label="收货人名称" width="150"></el-table-column>
  <el-table-column prop="billing_time" label="开票时间" width="140" :formatter="timeFormat"></el-table-column>
  <el-table-column prop="receiver_telephone" label="收货人电话" width="120"></el-table-column>
  <el-table-column prop="departure_status" label="出港状态" :formatter="depStateFormat"></el-table-column>
  <el-table-column prop="sender_telephone" label="发货人电话" width="120"></el-table-column>
  <el-table-column prop="correspond_order_no" label="对应单号" width="200"></el-table-column>
</el-table>
<el-pagination
  v-if="total"
  @current-change="pageChange"
  :current-page="searchInfo.params.currPage"
  :page-size="10"
  layout="total, prev, pager, next, jumper"
  :total="total">
</el-pagination>
 </div>
    </div>
</template>

交互

  <script>
 import {getReciveList} from "../../service"
 import {formatTime} from "../../utils/time.js"
  export default {
data() {
  return {
    type: '',
    title: '收货主单',
    searchInfo: {
      params: {
        type: 0,
        order_three_code: '', // 单号三字码
        order_num: '',  // 单号八位数字
        receipt_type: '', // 单据类型
        easy_flag: '', // 制单类型
        departure_status: '', // 出港状态
        departure: '', // 始发站
        destination: '', // 目的站
        sender: '', // 发货人,
        receiver: '', // 收货人,
        billing_time_start: '', // 开始日期
        billing_time_end: '', // 结束日期
        currPage: 1,
      },
      timeValue: '',
    },
    pickerOptions: {
      shortcuts: [{
        text: '最近一周',
        onClick(picker) {
          const end = new Date();
          const start = new Date();
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
          picker.$emit('pick', [start, end]);
        }
      }, {
        text: '最近一个月',
        onClick(picker) {
          const end = new Date();
          const start = new Date();
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
          picker.$emit('pick', [start, end]);
        }
      }, {
        text: '最近三个月',
        onClick(picker) {
          const end = new Date();
          const start = new Date();
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
          picker.$emit('pick', [start, end]);
        }
      }]
    },
    tableData: [],
    total: '',
  }
},
watch: {
  '$route'() {
    this.load()
  }
},
mounted() {
  this.load()
},
methods: {
  load() {
    this.type = this.$route.params.type
    this.searchInfo.params.type = this.type === 'sub' ? 1 : 0
    this.title = this.type === 'sub' ? '收货分单' : '收货主单'
    this.search()
  },
  search() {
    this.searchInfo.params.billing_time_start = this.searchInfo.timeValue[0] || ''
    this.searchInfo.params.billing_time_end = this.searchInfo.timeValue[1] || ''
    getReciveList(this.searchInfo.params).then(res => {
      this.tableData = res.data.data[0].list
      this.total = res.data.data[0].total
    })
  },
  
  add() {
    this.$store.commit('CHANGE_TOPTITLE', this.title + '-添加')
    this.$router.push(`/receive/${this.type}/billing/detail`)
  },
  reset() {
    this.$refs['searchForm'].resetFields()
  },
  edit(item) {
    this.$store.commit('CHANGE_TOPTITLE', this.title + '-编辑')
    this.$router.push(`/receive/${this.type}/billing/detail/${item.order_no}`)
  },
  stateFormat(row, column, cellValue) {
    return cellValue ? '是' : '否'
  },
  depStateFormat(row, column, cellValue) {
    let stateArr = ['未出港','部分出港','已出港']
    return stateArr[cellValue]
  },
  timeFormat(row, column, cellValue) {
    return formatTime(cellValue)
  },
  pageChange(val) {
    this.searchInfo.params.currPage = val
    this.search()
  },
  indexMethod(index) {
    return (this.searchInfo.params.currPage - 1)*10 + index + 1
  },
  tableRowClassName({row}) {
    if(row.easy_flag) {
      return 'warning-row'
    }else {
      return 'success-row'
    }
  }
}
}
</script>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 162,825评论 4 377
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,887评论 2 308
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 112,425评论 0 255
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,801评论 0 224
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,252评论 3 299
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 41,089评论 1 226
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,216评论 2 322
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 31,005评论 0 215
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,747评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,883评论 2 255
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,354评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,694评论 3 265
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,406评论 3 246
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,222评论 0 9
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,996评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,242评论 2 287
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 36,017评论 2 281

推荐阅读更多精彩内容