123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>入境登记-添加/修改</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <!-- 所有的 css js 资源 -->
- <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
- <link rel="stylesheet" href="../../static/sa.css">
- <script src="../../static/kj/vue.min.js"></script>
- <script src="../../static/kj/element-ui/index.js"></script>
- <script src="../../static/kj/httpVueLoader.js"></script>
- <script src="../../static/kj/jquery.min.js"></script>
- <script src="../../static/kj/layer/layer.js"></script>
- <script src="../../static/sa.js"></script>
- <script src="../../static/kj/upload-util.js"></script>
- <style type="text/css">
- .c-panel .el-form .c-label{width: 7em !important;}
- .c-panel .el-form .c-panel .el-form {width: 180px;}
- </style>
- </head>
- <body>
- <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
- <!-- ------- 内容部分 ------- -->
- <div class="s-body">
- <div class="c-panel">
- <div class="c-title" v-if="id == 0">数据添加</div>
- <div class="c-title" v-else>数据修改</div>
- <el-form v-if="m" label-position="left">
- <el-row>
- <el-col span=10>
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <span>基本资料</span>
- </div>
- <div>
- <div class="c-item" v-show="currentCustomerId==1">
- <label class="c-label">客户:</label>
- <el-select v-model="m.customerId" placeholder="请选择">
- <el-option
- v-for="item in customerList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </div>
- <div class="c-item">
- <label class="c-label">车牌号:</label>
- <el-autocomplete
- v-model="m.cardNo"
- @select="handleSelectCar"
- value-key='cardNo'
- :fetch-suggestions="queryCarAsync">
- </el-autocomplete>
- </div>
- <sa-item type="text" name="车规格" v-model="m.cardSize" br></sa-item>
- <sa-item type="text" name="运输货品" v-model="m.goodsName" br></sa-item>
- <sa-item type="num" name="载重(kg)" v-model="m.netWeight" br></sa-item>
- <div class="c-item">
- <label class="c-label">司机身份证:</label>
- <el-autocomplete
- v-model="m.driverIdCard"
- @select="handleSelectDriver"
- value-key='idCard'
- :fetch-suggestions="queryDriverAsync">
- </el-autocomplete>
- </div>
- <sa-item type="text" name="司机名称" v-model="m.driverName" br></sa-item>
- <sa-item type="text" name="司机联系号码" v-model="m.driverPhone" br></sa-item>
- </div>
- </el-card>
- </el-col>
-
- <el-col span=14>
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <span>业务项</span>
- </div>
- <div>
- <el-form-item v-for="(type,index) in itemTypeList" :label="type.name">
- <el-select v-model="type.itemId" style="width: 120px;" placeholder="请选择">
- <el-option
- v-for="item in type.items"
- :key="item.id"
- :label="item.itemName"
- :value="item.id">
- </el-option>
- </el-select>
- <el-input-number style="width: 180px;margin-left: 80px;" v-model="type.num" :min="1" :max="10" size="mini"></el-input-number>
- </el-form-item>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <sa-item name="" class="s-ok" br>
- <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
- </sa-item>
- </el-form>
- </div>
- </div>
- <!-- ------- 底部按钮 ------- -->
- <div class="s-foot">
- <el-button type="primary" @click="ok()">确定</el-button>
- <el-button @click="sa.closeCurrIframe()">取消</el-button>
- </div>
- </div>
- <script>
-
- var app = new Vue({
- components: {
- "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
- },
- el: '.vue-box',
- data: {
- id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
- m: {
- id: '', // 主键
- customerId: '', // 客户id
- customerName: '', // 客户名称
- no: '', // 编号
- cardNo: '', // 车牌号
- cardSize: '', // 车规格
- netWeight: '', // 载重(kg)
- goodsName: '', // 商品
- driverName: '', // 司机名称
- driverPhone: '', // 司机联系号码
- driverIdCard: '', // 司机身份证
- payTicket: '', // 支付凭证
- }, // 实体对象
- customerList:[],
- cardList:[],
- driverList:[],
- currentCustomerId:1,
- itemTypeList:[]
- },
- methods: {
- getItemTypeList(){
- sa.ajax('/TbItemType/getList',function(resp){
- let typeList=resp.data;
- // 初始化数据
- if(this.id > 0) {
- sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
- let m=res.data;
- let items=m.items;
- console.log(items);
- for(let i in items){
- let item=items[i];
- for(let j in typeList){
- let type=typeList[j];
- if(item.itemTypeId==type.id){
- type.itemId=item.itemId;
- type.num=item.num;
- }
- }
- }
- this.m = m;
- }.bind(this))
- }
- this.itemTypeList=typeList;
- }.bind(this))
- },
- getCardList(){
- sa.ajax('/TbCar/getList', {pageNo:1,pageSize:100}, function(resp) {
- this.cardList=resp.data;
- }.bind(this));
- },
- queryCarAsync(queryStr,cb){
- let list=this.cardList;
- let filterList= list.filter(obj=>obj.cardNo.indexOf(queryStr)!==-1);
- cb(filterList)
- },
- handleSelectCar(item){
- this.m.cardSize=item.cardSize;
- this.m.goodsName=item.lastGoodsName
- },
- getDriverList(){
- sa.ajax('/TbDriver/getList', {pageNo:1,pageSize:100}, function(resp) {
- this.driverList=resp.data;
- }.bind(this));
- },
- queryDriverAsync(queryStr,cb){
- let list=this.driverList;
- let filterList= list.filter(obj=>obj.idCard.indexOf(queryStr)!==-1);
- cb(filterList)
- },
- handleSelectDriver(item){
- this.m.driverId=item.id;
- this.m.driverName=item.name;
- this.m.driverIdCard=item.idCard;
- this.m.driverPhone=item.phone
- },
- getCustomerList(){
- sa.ajax('/TbCostomer/getList', {pageNo:1,pageSize:100}, function(resp) {
- this.customerList=resp.data;
- }.bind(this));
- },
- getCustomer(){
- sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
- let id=resp.data;
- if(id==1){
- this.getCustomerList();
- }else{
- this.m.customerId=id;
- }
- this.currentCustomerId=id;
- }.bind(this));
- },
- // 提交数据
- ok: function(){
- let itemList=this.itemTypeList.filter(obj=>obj.itemId);
- let list=[];
- for(let i in itemList){
- let item=itemList[i];
- if(!item.num||item.num<=0){
- this.$message({
- message: '请填写【'+item.name+'】数量',
- type: 'error'
- });
- return;
- }
- list.push({
- itemId:item.itemId,
- num:item.num
- })
- }
- // 表单校验
- let m = this.m;
- m.itemJson=JSON.stringify(list);
- m.items=[];
- if(this.currentCustomerId==1){
- sa.checkNull(m.customerId, '请选择 [客户名称]');
- }
- sa.checkNull(m.cardNo, '请输入 [车牌号]');
- sa.checkNull(m.cardSize, '请输入 [车规格]');
- sa.checkNull(m.netWeight, '请输入 [载重]');
- sa.checkNull(m.goodsName, '请输入 [商品]');
- sa.checkNull(m.driverName, '请输入 [司机名称]');
- sa.checkNull(m.driverPhone, '请输入 [司机联系号码]');
- sa.checkNull(m.driverIdCard, '请输入 [司机身份证]');
- if(this.id <= 0) { // 添加
- sa.ajax('/TbBusiness/add', m, function(res){
- sa.alert('增加成功', this.clean);
- }.bind(this));
- } else { // 修改
- sa.ajax('/TbBusiness/update', m, function(res){
- sa.alert('修改成功', this.clean);
- }.bind(this));
- }
- },
- // 添加/修改 完成后的动作
- clean: function() {
- if(this.id == 0) {
- this.m = this.createModel();
- } else {
- parent.app.f5(); // 刷新父页面列表
- sa.closeCurrIframe(); // 关闭本页
- }
- }
- },
- mounted: function(){
-
- this.getCustomer();
- this.getCardList();
- this.getDriverList();
- this.getItemTypeList();
- }
- })
-
- </script>
- </body>
- </html>
|