| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 | <!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>		<style type="text/css">			.c-panel .el-form .c-label {				width: 7em !important;			}			.num .el-input__inner {				width: 96px;			}			.c-panel .el-form .el-input,			.c-panel .el-form .el-textarea__inner {				width: 250px;			}		</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">						<el-row>							<el-col span=12>								<div class="c-item">									<label class="c-label">归属:</label>									<el-select v-model="m.customerId" placeholder="请选择" size="mini" filterable>										<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-select v-model="m.carType" placeholder="请选择" size="mini">										<el-option v-for="item in typeList" :key="item.value" :label="item.name"											:value="item.value">										</el-option>									</el-select>								</div>								<sa-item type="text" name="车牌号" v-model="m.cardNo" placeholder="请输入车牌号" br></sa-item>								<div class="c-item">									<label class="c-label">车长(米):</label>									<el-input-number class="num" step="0.5" :min="2" :max="40" size="small"										v-model="m.cardSize" controls-position="right"></el-input-number>								</div>								<div class="c-item">									<label class="c-label">载重(吨):</label>									<el-input-number class="num" step="0.5" :min="2" :max="40" size="small"										v-model="m.weight" controls-position="right"></el-input-number>								</div>							</el-col>							<el-col span=12>								<sa-item type="text" name="联系人" v-model="m.people" placeholder="联系人" br></sa-item>								<sa-item type="text" name="联系电话" v-model="m.phone" placeholder="联系电话" br></sa-item>								<sa-item type="textarea" name="备注" v-model="m.remark" placeholder="备注" br></sa-item>							</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()" v-if="sa.isAuth('tb-car-add')">确定</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: '', // 主键						cardNo: '', // 名称 						cardSize: '', // 规格 						customerId: '',						carType: 1,						weight: 4.8,						phone: '',						people: '',						remark: ''					}, // 实体对象 					customerList: [],					typeList: [{							value: 0,							name: '临时车'						},						{							value: 1,							name: '行政车'						},						{							value: 2,							name: '业务车'						},					]				},				methods: {					getCustomerList() {						sa.ajax('/TbCostomer/getListAndAdmin', function(resp) {							let list = resp.data;							this.customerList = list;							this.m.customerId = list[0].id;						}.bind(this))					},					// 提交数据 					ok: function() {						// 表单校验 						let m = this.m;						let carNo = m.cardNo;						sa.checkNull(carNo, '请输入 [车牌号]');						m.cardNo = carNo.toUpperCase();						// if(!sa.isCarNo(carNo)){						// 	sa.error('请输入正确的车牌号');						// 	return;						// }						let phone = m.phone;						if (phone && !sa.isPhone(phone)) {							sa.error('请输入正确手机号');							return;						}						let customerId = m.customerId;						m.customerName = this.customerList.filter(obj => obj.id == customerId)[0].name;						// 开始增加或修改						if (this.id <= 0) { // 添加							sa.ajax('/TbCar/add', m, function(res) {								sa.alert('增加成功', this.clean);							}.bind(this));						} else { // 修改							sa.ajax('/TbCar/update', m, function(res) {								sa.alert('修改成功', this.clean);							}.bind(this));						}					},					// 添加/修改 完成后的动作					clean: function() {						if (this.id == 0) {} else {							parent.app.f5(); // 刷新父页面列表							sa.closeCurrIframe(); // 关闭本页 						}					}				},				mounted: function() {					this.getCustomerList();				}			})		</script>	</body></html>
 |