Commit ba46222a authored by lixy's avatar lixy

旅游管理

parent f1227342
<template> <template>
<div> <div>
<!-- 图片上传组件辅助--> <!-- 图片上传组件辅助-->
<!--<el-upload-->
<!--class="avatar-uploader"-->
<!--name="img"-->
<!--:headers="getHeaderWithToken"-->
<!--action="https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload"-->
<!--:show-file-list="false"-->
<!--:on-success="uploadSuccess"-->
<!--:on-error="uploadError"-->
<!--:before-upload="beforeUpload">-->
<!--</el-upload>-->
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
:action="'https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload'" :action="'https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload'"
...@@ -23,7 +13,7 @@ ...@@ -23,7 +13,7 @@
<quill-editor <quill-editor
class="editor" class="editor"
v-model="content" v-model="content"
ref="myQuillEditor" :ref="myQuillEditor"
:options="editorOption" :options="editorOption"
@blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
@change="onEditorChange($event)"> @change="onEditorChange($event)">
...@@ -65,10 +55,16 @@ ...@@ -65,10 +55,16 @@
value: { value: {
type: String type: String
}, },
myQuillEditor: {
type: String
},
/*图片大小*/ /*图片大小*/
maxSize: { maxSize: {
type: Number, type: Number,
default: 4000 //kb default: 4000 //kb
},
activeName2:{
type: String
} }
}, },
...@@ -85,6 +81,7 @@ ...@@ -85,6 +81,7 @@
return { return {
content: this.value, content: this.value,
quillUpdateImg: false, // 根据图片上传状态来确定是否显示loading动画,刚开始是false,不显示 quillUpdateImg: false, // 根据图片上传状态来确定是否显示loading动画,刚开始是false,不显示
quill: undefined,
editorOption: { editorOption: {
placeholder: "", placeholder: "",
theme: "snow", // or 'bubble' theme: "snow", // or 'bubble'
...@@ -114,7 +111,6 @@ ...@@ -114,7 +111,6 @@
} }
} }
}, },
serverUrl: this.baseServerUrl+"/fileUpload/uploadPic?filepath=artwork", // 这里写你要上传的图片服务器地址
header: { header: {
// token: sessionStorage.token // token: sessionStorage.token
} // 有的图片服务器要求请求头需要有token } // 有的图片服务器要求请求头需要有token
...@@ -125,13 +121,29 @@ ...@@ -125,13 +121,29 @@
this.content = value; this.content = value;
} }
}, },
mounted() {
debugger
// switch(this.activeName2){
// case "first":
// this.myQuillEditor="myQuillEditorExplain";
// break;
//
// };
let tt = this.$refs;
this.quill = tt[this.myQuillEditor].quill;
console.log(this.quill);
console.log(this.activeName2);
},
methods: { methods: {
onEditorBlur() { onEditorBlur() {
//失去焦点事件 //失去焦点事件
}, },
onEditorFocus() { onEditorFocus(e) {
//获得焦点事件 //获得焦点事件
// let tt = this.$refs;
// this.quill = tt[this.myQuillEditor].quill;
// console.log(this.quill);
}, },
onEditorChange() { onEditorChange() {
//内容改变事件 //内容改变事件
...@@ -148,8 +160,10 @@ ...@@ -148,8 +160,10 @@
console.log(file) console.log(file)
// res为图片服务器返回的数据 // res为图片服务器返回的数据
// 获取富文本组件实例 // 获取富文本组件实例
debugger // let quill = this.$refs.myQuillEditor.quill;
let quill = this.$refs.myQuillEditor.quill; let tt = this.$refs;
console.log(tt);
let quill = this.quill;//tt[this.myQuillEditor].quill;
// 如果上传成功 // 如果上传成功
if (res.status == 200) { if (res.status == 200) {
// 获取光标所在位置 // 获取光标所在位置
......
<template>
<div class="app-container calendar-list-container" v-loading.body="showLoadingBody">
<div v-if="!oneTourDialogVisible">
<div class="filter-container" ref="filter-container">
<el-form :rules="rules4Query" ref="queryForm" :inline="inline" :model="listQuery" label-width="100px">
<el-row>
<el-col :span="8">
<el-form-item label="旅行名称">
<el-input v-model.number="listQuery.code" placeholder="请输入旅行名称"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="标签">
<el-select class="filter-item" v-model="listQuery.status" placeholder="请选择标签">
<el-option :key="undefined" label="无" :value="undefined"></el-option>
<el-option v-for="(val, key, index) in getAllVehicleStatus() " :key="val.code" :label="val.val"
:value="val.code"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate"
type="primary" icon="edit">添加
</el-button>
</div>
<el-table :key='tableKey' :data="list" border fit highlight-current-row
style="width: 100%">
<el-table-column
type="index"
align="center" label="序号" width="65">
</el-table-column>
<el-table-column width="666" align="center" label="旅行名称/价格">
<template scope="scope">
<img :src="scope.row.cover" style="width: 30px;"/>
<span>{{scope.row.name}}{{scope.row.price}}/{{scope.row.unit}}</span>
</template>
</el-table-column>
<el-table-column width="300" align="center" label="标签">
<template scope="scope">
<span>{{scope.row.tagNames}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="总数量">
<template scope="scope">
<span>{{scope.row.stock}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="销量">
<template scope="scope">
<span>{{scope.row.saleCount}}</span>
</template>
</el-table-column>
<el-table-column align="center" width="200" label="操作">
<template scope="scope">
<el-button v-if="tourManage_btn_edit" size="small" type="success" @click="handleUpdate(scope.row)">编辑
</el-button>
<el-button size="small" type="warn" @click="undercarriageHandler(scope.row)">下架
</el-button>
<el-button size="small" type="danger" @click="deleteHandler(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
<div v-show="!listLoading" class="pagination-container">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page.sync="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit"
layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
</div>
</div>
<!-- 旅游modal弹窗 -->
<oneTour v-if="oneTourDialogVisible" :oneTourRow="oneTourRow" :title="modalTitle" v-on:oneTourDialogEvent = "oneTourDialogEvent"></oneTour>
</div>
</template>
<script>
import oneTour from './modal/oneTourModal'// 旅游
import 'static/css/uploadImg.css';// 引入图片上传组件对话框
import {
formatDate
} from 'utils/dateFormattor';
import {
toEast8Date,
deepCopyDate,
newEast8Date,
convertDate2Str
} from 'utils/dateUtils';
import rsCode from '../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
getToken
} from 'utils/auth';
import {
page,
goodsEdit
} from 'api/tourManage';
import Element1 from "../admin/menu/components/element";
import ElRow from "element-ui/packages/row/src/row";
import ElCol from "element-ui/packages/col/src/col";
export default {
name: 'tourManage',
components: {
ElCol,
ElRow,
Element1,
oneTour
},
data() {
return {
modalTitle: "创建",
BASE_API: process.env.BASE_API,
oneTourDialogVisible: false,//添加、编辑弹框
showLoadingBody: false,
form: {
tagNames:"",//标签
name: undefined,//旅游名称
saleCount: undefined,//销量
stock: undefined,//总数量
},
rules: {
subordinateBranch: [
{
type: 'integer',
required: true,
message: '请选择公司',
trigger: 'blur'
}
],
maintenanceMileage: [this.integerValidator()],
code: [
{
validator: (rule, value, callback) => {
if (this.$utils.isUndefined(value) || this.$utils.isNull(value)) {
return callback();
}
if (!this.$utils.isInteger(value)) {
return callback(new Error('编码必须为整数'));
}
if (value < 1 || value > 9999999999) {
return callback(new Error('编码合法范围:[1 - 9999999999]'));
}
callback();
},
trigger: 'blur'
}
],
vin: [
{
min: 0,
max: 200,
message: '长度小于 200 个字符',
trigger: 'blur'
}
],
numberPlate: [
{
min: 0,
max: 20,
message: '长度小于 20 个字符',
trigger: 'blur'
}
],
remark: [
{
min: 0,
max: 2000,
message: '长度小于 2000 个字符',
trigger: 'blur'
}
]
},
pickerOptions4Apply: {
disabledDate: this.checkBookDate
},
rules4Query: {
vin: [
{
min: 0,
max: 200,
message: '长度小于 200 个字符',
trigger: 'blur'
}
],
subordinateBranch: [
{
validator: (rule, value, callback) => {
if ((this.$utils.isString(this.listQuery.bookedStartDate) && this.listQuery.bookedStartDate !== '') ||
(this.$utils.isString(this.listQuery.bookedEndDate) && this.listQuery.bookedEndDate !== '') ||
(this.$utils.isString(this.listQuery.notBookedStartDate) && this.listQuery.notBookedStartDate !== '') ||
(this.$utils.isString(this.listQuery.notBookedEndDate) && this.listQuery.notBookedEndDate !== '')) {
if (!this.listQuery.subordinateBranch) {
return callback(new Error('若需按预定日期查询车辆,选择分公司'));
}
}
callback();
},
trigger: 'blur'
}
],
notBookDateRange: [
{
validator: (rule, value, callback) => {
if (this.notBookDateRange) {
let startDate = toEast8Date(this.listQuery.notBookedStartDate);
let endDate = toEast8Date(this.listQuery.notBookedEndDate);
if (this.$utils.isDate(startDate) && startDate.setMonth(startDate.getMonth() + 2) < endDate) {
return callback(new Error('日期范围不能超过2个月'));
}
}
callback();
},
trigger: 'blur'
}
],
bookDateRange: [
{
validator: (rule, value, callback) => {
if (this.bookDateRange) {
let startDate = toEast8Date(this.listQuery.bookedStartDate);
let endDate = toEast8Date(this.listQuery.bookedEndDate);
if (this.$utils.isDate(startDate) && startDate.setMonth(startDate.getMonth() + 2) < endDate) {
return callback(new Error('日期范围不能超过2个月'));
}
}
callback();
},
trigger: 'blur'
}
]
},
rules4Apply: {
bookDateRange4Apply: [
{
validator: (rule, value, callback) => {
if (!this.$utils.isArray(this.bookDateRange4Apply) || this.bookDateRange4Apply.length === 0) {
return callback(new Error('请输入预定时间。'));
}
let [oriStartDate, ortEndDate] = this.bookDateRange4Apply;
if (!this.$utils.isDate(oriStartDate) || !this.$utils.isDate(ortEndDate)) {
return callback(new Error('请输入预定时间。'));
}
let [startDate, endDate] = [deepCopyDate(oriStartDate), deepCopyDate(ortEndDate)];
if (!this.$utils.isDate(oriStartDate) || !this.$utils.isDate(ortEndDate)) {
return callback();
}
for (let curDate = startDate; curDate <= endDate; curDate.setDate(curDate.getDate() + 1)) {
if (this.checkBookDate(curDate)) {
return callback(new Error('请选择从今天起两个月内,未预定的时间。'));
}
}
callback();
},
required: true,
trigger: 'blur'
}
],
liftCompany: [
{
required: true,
message: '请选择提车分公司',
trigger: 'blur',
type: 'integer'
}
],
retCompany: [
{
required: true,
message: '请选择还车分公司',
trigger: 'blur',
type: 'integer'
}
],
destination: [
{
min: 0,
max: 200,
message: '长度小于 200 个字符',
trigger: 'blur'
}
],
remark: [
{
min: 0,
max: 2000,
message: '长度小于 2000 个字符',
trigger: 'blur'
}
]
},
selectArry:[],
list: null,
total: null,
listLoading: true,
listQuery: {
page: 1,
limit: 20
},
inline: true,
tourManage_btn_edit: false,//编辑
tourManage_btn_add: false,//添加
vehicleInfo_btn_apply: false,
allCompanies: {},
allCompaniesArr: [],
textMap: {
update: '编辑',
create: '创建'
},
tableKey: 0,
departureDialogVisible: false,
arrivalDialogVisible: false
}
},
created() {
this.getList();
this.tourManage_btn_edit = true;//this.elements['tourManage:btn_edit'];
this.tourManage_btn_add = true;//this.elements['tourManage:btn_add'];
},
computed: {
...mapGetters([
'elements',
'belong2Type',
'vehicleStatus'
]),
provinceRegions() {
return getSonRegionByCodes(1);
},
cityRegions() {
if (!this.$utils.isInteger(this.form.addrProvince)) {
return null;
}
return getSonRegionByCodes(this.form.addrProvince);
},
townRegions() {
if (!this.$utils.isInteger(this.form.addrCity)) {
return null;
}
return getSonRegionByCodes(this.form.addrCity);
},
cityRegions4Query() {
if (!this.$utils.isInteger(this.listQuery.addrProvince)) {
return null;
}
return getSonRegionByCodes(this.listQuery.addrProvince);
},
townRegions4Query() {
if (!this.$utils.isInteger(this.listQuery.addrCity)) {
return null;
}
return getSonRegionByCodes(this.listQuery.addrCity);
},
getHeaderWithToken() {
return {Authorization: getToken()};
},
getSelectedAccItemStr() {
if (!this.$utils.isEmpty(this.form4Apply.selectedAccItem)) {
let rsStr = '';
for (let key in this.form4Apply.selectedAccItem) {
rsStr = rsStr + this.$refs.accItemSelector.getNameById(key) + ' : ' + this.form4Apply.selectedAccItem[key] + '\n';
}
return rsStr;
}
return '';
},
getUnkownBrandCode: () => VEHICLE_CONSTANT_BRAND_CODE_UNKOWN,
getCurBookedInfo: function () {
if (!this.$utils.isEmpty(this.curBookedInfo3Month) && this.curBookedInfo3Month.length > 0) {
let rs = {};
for (let index in this.curBookedInfo3Month) {
rs[this.curBookedInfo3Month[index].yearMonth] = this.curBookedInfo3Month[index].bookedDate;
}
return rs;
}
return undefined;
},
bookDateRange: {
get: function () {
let startDate = undefined;
let endDate = undefined;
if (this.$utils.isString(this.listQuery.bookedStartDate) && this.listQuery.bookedStartDate !== '') {
startDate = toEast8Date(this.listQuery.bookedStartDate);
}
if (this.$utils.isString(this.listQuery.bookedEndDate) && this.listQuery.bookedEndDate !== '') {
endDate = toEast8Date(this.listQuery.bookedEndDate);
}
return [startDate, endDate];
},
set: function ([startDate, endDate]) {
if (this.$utils.isDate(startDate)) {
this.listQuery.bookedStartDate = formatDate(startDate, 'yyyy-MM-dd');
} else {
this.listQuery.bookedStartDate = undefined;
}
if (this.$utils.isDate(endDate)) {
this.listQuery.bookedEndDate = formatDate(endDate, 'yyyy-MM-dd');
} else {
this.listQuery.bookedEndDate = undefined;
}
}
},
notBookDateRange: {
get: function () {
let startDate = undefined;
let endDate = undefined;
if (this.$utils.isString(this.listQuery.notBookedStartDate) && this.listQuery.notBookedStartDate !== '') {
startDate = toEast8Date(this.listQuery.notBookedStartDate);
}
if (this.$utils.isString(this.listQuery.notBookedEndDate) && this.listQuery.notBookedEndDate !== '') {
endDate = toEast8Date(this.listQuery.notBookedEndDate);
}
return [startDate, endDate];
},
set: function ([startDate, endDate]) {
if (this.$utils.isDate(startDate)) {
this.listQuery.notBookedStartDate = formatDate(startDate, 'yyyy-MM-dd');
} else {
this.listQuery.notBookedStartDate = undefined;
}
if (this.$utils.isDate(endDate)) {
this.listQuery.notBookedEndDate = formatDate(endDate, 'yyyy-MM-dd');
} else {
this.listQuery.notBookedEndDate = undefined;
}
}
},
bookDateRange4Apply: {
get: function () {
let startDate = undefined;
let endDate = undefined;
if (this.$utils.isString(this.form4Apply.bookStartDate) && this.form4Apply.bookStartDate !== '') {
startDate = toEast8Date(this.form4Apply.bookStartDate);
}
if (this.$utils.isString(this.form4Apply.bookEndDate) && this.form4Apply.bookEndDate !== '') {
endDate = toEast8Date(this.form4Apply.bookEndDate);
}
return [startDate, endDate];
},
set: function ([startDate, endDate]) {
if (this.$utils.isDate(startDate)) {
this.form4Apply.bookStartDate = formatDate(startDate, 'yyyy-MM-dd');
} else {
this.form4Apply.bookStartDate = undefined;
}
if (this.$utils.isDate(endDate)) {
this.form4Apply.bookEndDate = formatDate(endDate, 'yyyy-MM-dd');
} else {
this.form4Apply.bookEndDate = undefined;
}
}
}
},
methods: {
/**
* 添加
* */
handleCreate() {
this.resetTemp();
this.modalTitle = '创建';
this.oneTourDialogVisible = true;
},
/**
* 操作-删除
* */
deleteHandler(row) {
this.oneTourRow = row;
this.oneTourDialogVisible = true;
},
/**
* 编辑
* */
handleUpdate(row) {
this.modalTitle = '编辑';
this.oneTourRow = row;
this.oneTourDialogVisible = true;
},
/**
* 下架
* */
undercarriageHandler(row) {
// open dialog
this.departureDialogVisible = true;
this.clearDepartureForm();
let that = this;
let selectArry = [];
this.allCompaniesArr.map(function(item){
item.value = item.name;
selectArry.push(item);
});
this.departureForm.mileage = row.mileage;
this.departureForm.expectArrivalBranchCompanyId = row.subordinateBranch;
this.departureForm.departureBranchCompanyId = row.subordinateBranch;
selectArry.map(function (iitem) {
if( row.subordinateBranch == iitem.id){
that.departureForm.departureBranchCompanyName = iitem.name;
that.departureForm.expectArrivalBranchCompanyName = iitem.name;
}
});
this.departureForm.vehicleId = row.id;
this.departureForm.numberPlate = row.numberPlate;
this.departureForm.departureDate = Date();
},
/**
* 旅游modal传递回来的数据
* */
oneTourDialogEvent(e){
if(!e){//关闭编辑
this.oneTourDialogVisible = e;
} else if(e){
//编辑成功-重新加载列表
this.getList();
}
},
clearDepartureForm() {
this.departureForm = {
vehicleId: null,
numberPlate: null,
departureBranchCompanyName: '',
departureDate: null,
departureBranchCompanyId: null,
use: null,
user: null,
userTel: null,
checkMan: null,
checkManTel: null,
expectArrivalBranchCompanyId: null,
expectArrivalBranchCompanyName: '',
mileage: null
}
},
departureVehicleHandler() {
console.log(this.departureForm);
if(this.departureForm.expectArrivalBranchCompanyName == "全部" || this.departureForm.expectArrivalBranchCompanyName == ''){
this.departureForm.expectArrivalBranchCompanyId = undefined;
}
if(this.departureForm.departureBranchCompanyName == "全部" || this.departureForm.departureBranchCompanyName == ''){
this.departureForm.departureBranchCompanyId = undefined;
}
departureVehicle(this.departureForm).then(response => {
if (response.code === rsCode.RS_CODE_SUC) {
this.departureDialogVisible = false;
this.$notify({
title: '成功',
message: '出车成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
},
getAllBelong2Type: function () {
return this.belong2Type;
},
getBelongToNameStr(row) {
if (!this.$utils.isInteger(row.belongTo)) {
return undefined;
}
if (BELONG_TO_TYPE_OWN === row.belongTo) {
return this.belong2Type[row.belongTo].val;
}
if (this.$utils.isString(row.belongToName) && !this.$utils.isEmpty(row.belongToName)) {
return row.belongToName;
}
return undefined;
},
showImgDialog(drivingLicensePath) {
this.licenceSrcUrl = this.getDrivingLicenseUrl(drivingLicensePath);
this.dialogForm4LicenceVisible = true;
},
getDrivingLicenseUrl(drivingLicensePath) {
return process.env.BASE_API +
'/vehicle/vehicleInfo/download/drivingLicense?realFileRelPath=' + encodeURI(drivingLicensePath);
},
handleAvatarSuccess(res, file) {
this.form.drivingLicensePath = res.data;
this.showLoadingBody = false;
},
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg' || file.type === 'image/gif';
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isJPG) {
this.$message.error('上传图片只能是 JPG/GIF 格式!');
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 10MB!');
}
this.showLoadingBody = true;
return isJPG && isLt2M;
},
accItemSelected(selected) {
this.form4Apply.selectedAccItem = selected;
},
accItemClear() {
this.form4Apply.selectedAccItem = undefined;
},
handleAccItemSelect() {
this.$refs.accItemSelector.show();
},
integerValidator: function () {
return {
validator: (rule, value, callback) => {
if (this.$utils.isUndefined(value) || this.$utils.isNull()) {
return callback();
}
if (!this.$utils.isInteger(value)) {
return callback(new Error('必须为整数'));
}
if (value < 1 || value > 9999999999) {
return callback(new Error('编码合法范围:[1 - 9999999999]'));
}
callback();
},
trigger: 'blur'
};
},
fillDateRange2Object: function (realBelong, rangePropName, startDatePropName, endDatePropName) {
if (this.$utils.isEmpty(realBelong) || !this.$utils.isArray(realBelong[rangePropName])) {
return realBelong;
}
let belong = this.$utils.clone(realBelong, true);
let [startDate, endDate] = belong[rangePropName];
if (this.$utils.isDate(startDate)) {
belong[startDatePropName] = formatDate(startDate, 'yyyy-MM-dd hh:mm:ss');
} else {
belong[startDatePropName] = undefined;
}
if (this.$utils.isDate(endDate)) {
belong[endDatePropName] = formatDate(endDate, 'yyyy-MM-dd hh:mm:ss');
} else {
belong[endDatePropName] = undefined;
}
belong[rangePropName] = undefined;
return belong;
},
fillDates2Range: function (belong, rangePropName, startDatePropName, endDatePropName) {
if (this.$utils.isEmpty(belong) || !this.$utils.isString(belong[startDatePropName]) || belong[startDatePropName] === '' ||
!this.$utils.isString(belong[endDatePropName]) || belong[endDatePropName] === '') {
return;
}
let [startDateStr, endDateStr] = [belong[startDatePropName], belong[endDatePropName]];
belong[rangePropName] = [toEast8Date(startDateStr), toEast8Date(endDateStr)];
},
changeDate4BookInfo: function (date) {
getBookedInfo(this.form4BookInfo.vehicle, date).then(response => {
this.curBookedInfo = response.data;
});
},
checkBookDate: function (time) {
let nowDate = newEast8Date();
if (this.$utils.toDateString(time, 'yyyy-MM-dd') < this.$utils.toDateString(nowDate, 'yyyy-MM-dd')) {
return true;
}
if (nowDate.setMonth(nowDate.getMonth() + 2) < time) {//预定范围两个月内
return true;
}
let curYearMonth = formatDate(time, 'yyyy-MM');
if (!this.$utils.isEmpty(this.getCurBookedInfo) && this.$utils.isInteger(this.getCurBookedInfo[curYearMonth])) {
let int4BitMap = this.getCurBookedInfo[curYearMonth];
let dayOfMonth = time.getDate();
return (int4BitMap & (1 << (dayOfMonth - 1))) != 0;
}
return false;
},
checkIfRuning: vehicle => vehicle.status === VEHICLE_CONSTANT_STATUS_NORMAL,
getVehicleStatus: function (code) {
return this.vehicleStatus[code].val;
},
getAllVehicleStatus: function () {
return this.vehicleStatus;
},
getBrand: function (code) {
if (!this.$utils.isInteger(code) || code == VEHICLE_CONSTANT_BRAND_CODE_UNKOWN) {
return '未知';
}
return getConstantByTypeAndCode(VEHICLE_CONSTANT_VEHICLE_BRAND, code).val;
},
getAllBranch: () => {
return getConstantListByType(VEHICLE_CONSTANT_VEHICLE_BRAND);
},
getUseType: function (code) {
if (!this.$utils.isInteger(code) || code == VEHICLE_CONSTANT_USE_TYPE_UNKOWN) {
return '未知';
}
return getConstantByTypeAndCode(VEHICLE_CONSTANT_VEHICLE_USE, code).val;
},
getAllUseType: () => {
return getConstantListByType(VEHICLE_CONSTANT_VEHICLE_USE);
},
/**
* 获取旅游列表
* */
getList() {
this.listLoading = true;
page(this.listQuery).then(response => {
let totalCountRs = undefined;
let listRs = undefined;
if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) {
listRs = response.data.data;
totalCountRs = response.data.totalCount;
}
this.listLoading = false;
this.list = listRs;
this.total = totalCountRs;
})
},
getAddrStr(branchCompany) {
let regions = getRegionByCodes([branchCompany.addrProvince, branchCompany.addrCity, branchCompany.addrTown]);
return regions[0].name + ' ' + regions[1].name + ' ' + regions[2].name + ' ';
},
handleFilter() {
this.listQuery.page = 1;
this.$refs.queryForm.validate(valid => {
if (valid) {
this.getList();
} else {
return false;
}
});
},
handleSizeChange(val) {
this.listQuery.limit = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.page = val;
this.getList();
},
/**
* 操作-申请预定
* */
handleApply(row) {
this.resetTemp4Apply();
let that = this;
let selectArry = [];
this.allCompaniesArr.map(function(item){
item.value = item.name;
selectArry.push(item);
});
this.form4Apply.liftCompany = row.subordinateBranch;
selectArry.map(function (iitem) {
if( row.subordinateBranch == iitem.id){
that.form4Apply.state3 = iitem.name;
}
});
this.form4Apply.vehicle = row.id;
getBookedInfoIn2Month(row.id)
.then(response => {
this.curBookedInfo3Month = response.data;
this.dialogStatus = 'apply';
this.dialogForm4ApplyVisible = true;
});
},
handleBookInfo(row) {
this.$refs.bookInfoViewer.handleBookInfo(row.id);
},
create(formName) {
const set = this.$refs;
if(!this.form.state2 || this.form.state2 == "全部"){
this.form.subordinateBranch = undefined;
this.$notify({
title: '失败',
message: '请选择分公司',
type: 'warning',
duration: 2000
});
return;
}
set[formName].validate(valid => {
if (valid) {
let formTemp = this.fillDateRange2Object(this.form, 'insuranceDateRange4form', 'insuranceStartDate', 'insuranceEndDate');
convertDate2Str(formTemp);
addObj(formTemp)
.then(response => {
if (response.code === rsCode.RS_CODE_SUC) {
this.dialogFormVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
} else {
return false;
}
});
},
cancel(formName) {
this.dialogFormVisible = false;
this.dialogForm4ApplyVisible = false;
this.$refs[formName].resetFields();
},
cancel4Apply(formName) {
this.dialogForm4ApplyVisible = false;
this.$refs[formName].resetFields();
},
update(formName) {
const set = this.$refs;
if(!this.form.state2 || this.form.state2 == "全部"){
this.form.subordinateBranch = undefined;
this.$notify({
title: '失败',
message: '请选择分公司',
type: 'warning',
duration: 2000
});
return;
}
set[formName].validate(valid => {
if (valid) {
let formTemp = this.fillDateRange2Object(this.form, 'insuranceDateRange4form', 'insuranceStartDate', 'insuranceEndDate');
convertDate2Str(formTemp);
putObj(formTemp).then(response => {
if (response.code === rsCode.RS_CODE_SUC) {
this.dialogFormVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '更新成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
} else {
return false;
}
});
},
/**
* 申请预定-确定
* @param formName
*/
apply(formName) {
if(!this.form4Apply.state3 || this.form4Apply.state3 == "全部"){
this.form4Apply.liftCompany = undefined;
this.$notify({
title: '失败',
message: '请选择提车分公司',
type: 'warning',
duration: 2000
});
return;
}
if(!this.form4Apply.state4 || this.form4Apply.state4 == "全部"){
this.form4Apply.retCompany = undefined;
this.$notify({
title: '失败',
message: '请选择还车分公司',
type: 'warning',
duration: 2000
});
return;
}
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
this.dialogFormVisible = false;
book(this.form4Apply).then(() => {
this.dialogForm4ApplyVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '预定成功',
type: 'success',
duration: 2000
});
});
} else {
return false;
}
});
},
resetTemp() {
this.form = {
tagNames:"",//标签
name: undefined,//旅游名称
saleCount: undefined,//销量
stock: undefined,//总数量
};
},
resetTemp4Apply() {
this.form4Apply = {
bookStartDate: undefined,
bookEndDate: undefined,
state3: '',
state4:'',
retCompany: undefined,
vehicle: undefined,
selectedAccItem: undefined,
liftCompany: undefined,
liftAddr: undefined,
destination: undefined,
remark: undefined
};
},
resetTemp4BookInfo() {
this.form4BookInfo = {
selectedMonth: this.$utils.toDateString(newEast8Date(), 'yyyy-MM'),
vehicle: undefined
};
}
}
}
</script>
<template>
<el-dialog title="出发地" :visible.sync="isVisible">
<el-button size="small" class="el-button el-button--primary" type="button" icon="plus" @click="addTime()">添加</el-button>
<el-form>
<el-row style="margin: 10px 0;" v-for="item in lists"
:key="item.id">
<el-col :span="8">
<el-form-item label="出发地" >
<el-autocomplete
class="inline-input"
style="margin-left: 10px;"
v-model="item.name"
:fetch-suggestions="querySearch"
placeholder="请输入内容"
@select="handleSelect"
></el-autocomplete>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="出发时间">
<el-input style="width: 150px;" v-model="item.departTimeNew" @blur="onEditorBlur(item)" placeholder="请输入出发时间"></el-input>
<div>格式0:0,8:0,8:30</div>
<!--<el-time-picker-->
<!--v-model="item.departTime"-->
<!--value-format="HH:mm"-->
<!--format="HH:mm"-->
<!--@change="changeTime(item)"-->
<!--placeholder="任意时间点">-->
<!--</el-time-picker>-->
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="排序">
<el-input style="width: 150px;" type="number" min="0" v-model="item.rank" placeholder="请输入排序"></el-input>
<el-button type="danger" size="small" @click="deleteItem(item)">删除</el-button>
</el-form-item>
</el-col>
<!--<el-col :span="3"> <el-button type="danger" size="small" @click="deleteItem(item)">删除</el-button></el-col>-->
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="okHandler('form')">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
import {
getSonRegionByCodes,
getRegionByCodes,
} from 'api/base_info/region/';
import rsCode from '../../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
formatDate
} from 'utils/dateFormattor';
import {
getAllCompany,
getAll
} from 'api/base_info/branch_company/';
import ElRow from "element-ui/packages/row/src/row";
import ElInput from "../../../../node_modules/element-ui/packages/input/src/input.vue";
import ElCol from "element-ui/packages/col/src/col";
import ElFormItem from "../../../../node_modules/element-ui/packages/form/src/form-item.vue";
import ElForm from "../../../../node_modules/element-ui/packages/form/src/form.vue";
export default {
props: ["list"],
name: 'destinationDialog',
components: {
ElForm,
ElFormItem,
ElCol,
ElInput,
ElRow
},
data() {
return {
isVisible: false,
time:"",
lists: [],//新增项
t: {},
num: 0,
obj:{}//新增项
}
},
created() {
getAll()
.then(response => {
this.allCompaniesArr = response.data;
});
getAllCompany(codeAndBranchCompany => {
this.allCompanies = codeAndBranchCompany;
});
},
watch: {
isVisible(newValue, oldValue){
if(!newValue){
this.$emit('departureEvent', false);
}
},
},
mounted() {
let that = this;
let arr = [];
this.list.map(function(item){debugger
item.h = parseInt(item.departTime / 3600);
item.s = (item.departTime-item.h*3600)/60;
item.departTimeNew = item.h+":"+item.s;
item.rank = item.rank?item.rank:0;
item.visible2 = false;
arr.push(item);
});
this.lists = arr;
this.isVisible = true;
},
computed: {
...mapGetters([
'elements',
])
},
methods: {
deleteHandler(){},
addTime(){
this.t = {
name: "",
rank: 0,
departTime: 28800,
};
this.lists.push(this.t);
},
/**
* 改变出发时间
* */
onEditorBlur(val){
let arr = val.departTimeNew.split(":");
val.departTime = arr[0]*3600+ arr[1]*60;
console.log(val);
},
changeTime(val){
// if(typeof val == "object"){
// let hour = val.departTime.getHours();
// let sec = val.departTime.getMinutes();
// val.departTime = hour*3600+ sec*60;
// console.log(val.departTime);
// }
},
/**
* 删除分公司出发地
* */
deleteItem(obj){
this.lists.splice(this.lists.indexOf(obj),1);
console.log(obj);
},
/**
* 确定
* */
okHandler() {
let arr = [];
// this.lists.map(function(item){
// // 时间转时间戳
// let hour = item.departTime_new.getHours();
// let sec = item.departTime_new.getMinutes();
// item.departTime = hour*3600+ sec*60;
// });
this.$emit('departureEvent', this.lists);
console.log( this.list)
},
/**
* 弹框-取消
* */
cancel() {
this.$emit('departureEvent', false);
},
querySearch(queryString, cb) {
let selectArry = [];
this.allCompaniesArr.map(function(item){
item.value = item.name;
selectArry.push(item);
});
this.selectArry = selectArry;
var results = queryString ? selectArry.filter(this.createFilter(queryString)) : selectArry;
// 调用 callback 返回建议列表的数据
cb(results);
},
handleSelect(item) {
this.lists.splice(this.lists.indexOf(item),1);
item.departTime = 28800;
this.lists.push(item);
},
createFilter(queryString) {
return (restaurant) => {
return (restaurant.name.indexOf(queryString.toLowerCase()) != -1);
};
},
}
}
</script>
<template>
<el-dialog :title="form.showTitle" :visible.sync="isVisible">
<el-form :model="form" :rules="rules" ref="form" label-width="120px">
<el-form-item :label="form.headTitle" prop="name">
<el-input v-model="form.name" placeholder="请输入名称"></el-input>
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="省份">
<el-select class="filter-item" v-model="listQuery.addrProvince" placeholder="请选择省份(直辖市)" @change='getValue'>
<el-option v-for="item in provinceRegions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="城市">
<el-select class="filter-item" v-model="listQuery.addrCity" placeholder="请选择城市">
<el-option v-for="item in cityRegions4Query" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="详细地址" prop="address">
<el-input v-model="form.address" placeholder="请输入详细地址"></el-input>
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="经度">
<el-input :value="form.latitude" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="纬度">
<el-input :value="form.longitude" readonly></el-input>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="拾取经纬度">
<el-input v-model="keyword" placeholder="请输入详细地址获取经纬度"></el-input>
</el-form-item>
<el-form-item v-if="1>2">
<baidu-map class="map" id="mapID" center="东莞市" :zoom="zoom" :scroll-wheel-zoom="true" @click="getPoint" @ready="handler">
<!--地图类型,两种:一种是路线一种是绿的那种-->
<bm-map-type :map-types="['BMAP_NORMAL_MAP', 'BMAP_HYBRID_MAP']" anchor="BMAP_ANCHOR_TOP_LEFT"></bm-map-type>
<!--地图搜索功能,绑定上面的input,-->
<!--display: none样式很关键,因为下面默认会有地址提示信息很长,很烦,这样搜索会很舒服,-->
<!--zoom是搜索结果的视图比例,个人觉得12.8很舒服显示-->
<bm-local-search :keyword="keyword" :auto-viewport="true" :location="location" zoom="12.8" style="display: none"></bm-local-search>
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
<!--信息窗口,show属性是控制显示隐藏,infoWindowClose和infoWindowOpen是控制信息窗口关闭隐藏的方法-->
<bm-marker :position="postionMap" >
<bm-info-window :show="show" class="bm-info" @close="infoWindowClose" @open="infoWindowOpen" style="font-size: 14px">
<!--<p>站点地址:{{ add.site }}</p>-->
</bm-info-window>
</bm-marker>
</baidu-map>
</el-form-item>
<el-form-item>
<!--:center="center"-->
<baidu-map
:zoom="zoom"
:dragging="true"
:scroll-wheel-zoom="true"
class="map"
@ready="handler"
@click="getPoint"
>
<bm-local-search
:keyword="keyword"
:auto-viewport="true"
:location="location"
style="display: none"
></bm-local-search>
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
<bm-geolocation
anchor="BMAP_ANCHOR_BOTTOM_RIGHT"
:showAddressBar="true"
:autoLocation="true"
></bm-geolocation>
<bm-marker :position="{lng:form.longitude, lat: form.latitude}"></bm-marker>
</baidu-map>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-popover
ref="popover5"
placement="top"
width="160"
v-model="visible2">
<p>确定删除吗?</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="visible2 = false">取消</el-button>
<el-button type="primary" size="mini" @click="deleteHandler()">确定</el-button>
</div>
</el-popover>
<el-button type="danger" v-popover:popover5>删除</el-button>
<el-button type="primary" @click="okHandler('form')">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
import BaiduMap from 'vue-baidu-map';
import {
getSonRegionByCodes,
getRegionByCodes,
} from 'api/base_info/region/';
import rsCode from '../../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
getAllCompany,
getAll
} from 'api/base_info/branch_company/';
import ElRow from "element-ui/packages/row/src/row";
import ElInput from "../../../../node_modules/element-ui/packages/input/src/input.vue";
import ElCol from "element-ui/packages/col/src/col";
import ElFormItem from "../../../../node_modules/element-ui/packages/form/src/form-item.vue";
export default {
props: ["obj"],
name: 'destinationDialog',
components: {
ElFormItem,
ElCol,
ElInput,
ElRow
},
data() {
return {
jgNameDialog: false,
show: false,
postionMap:{ //地图坐标
lng: 120.211486,
lat: 30.256576
},
visible2: false,//是否显示删除确认框
location: '',
keyword: '', //搜索框关键词
zoom: 12.8, //放大比例
address:'', //位置详细信息
add:{
siteName:'',
site:'',
jd:'',
wd:'',
desce:'',
type:'',
jgName:'',
jgNum:'',
},
organizationData:[],
jgName:'',
jgNum:'',
form: {
showTitle: "",//弹框名称
name: undefined,//地址名称
keyword:"",//根据关键词查找经纬度
address:undefined,//详细地址
longitude: undefined,
latitude:undefined,
eventName: undefined
},
listQuery: {
addrProvince: undefined,
addrCity: undefined,
},
rules: {
name: [
{
type: 'string',
required: true,
message: '请输入名称',
trigger: 'blur'
},
{
min: 0,
max: 2000,
message: '长度小于 2000 个字符',
trigger: 'blur'
}
],
address: [
{
type: 'string',
required: true,
message: '请输入详细地址',
trigger: 'blur'
},
{
min: 0,
max: 2000,
message: '长度小于 2000 个字符',
trigger: 'blur'
}
],
longitude:{
type: 'string',
required: true,
message: '请输入经纬度',
trigger: 'blur'
},
latitude:{
type: 'string',
required: true,
message: '请输入经纬度',
trigger: 'blur'
},
addrProvince:{
required: true,
message: '请选择省份',
trigger: 'blur'
},
addrCity:{
required: true,
message: '请选择城市',
trigger: 'blur'
},
},
allCompanies: {},
allCompaniesArr: [],
isVisible: false,
allUpkeepItems: null,
dialogStatus: undefined,
baidumapSwitch:false,
zoom: 16,
location: "深圳市",
}
},
created() {
},
watch: {
isVisible(newValue, oldValue){
if(!newValue){
this.$emit(this.form.eventName, false);
this.cleanForm();
}
},
},
mounted() {
let that = this;
let row = this.obj;
this.cleanForm();
this.form = this.obj;
this.listQuery.addrProvince = this.obj.province;
this.listQuery.addrCity = this.obj.city;
this.keyword = row.keyword;
this.isVisible = true;
},
computed: {
...mapGetters([
'elements',
]),
provinceRegions() {
return getSonRegionByCodes(1);
},
cityRegions4Query() {
if (!this.$utils.isInteger(this.listQuery.addrProvince)) {
return null;
}
return getSonRegionByCodes(this.listQuery.addrProvince);
},
},
methods: {
/**
* 删除
* */
deleteHandler(formName) {
// 删除
this.form.method = 'delete';
this.$emit(this.form.eventName, this.form);
},
querySearch(queryString, cb) {
let selectArry = [];
this.allCompaniesArr.map(function(item){
item.value = item.name;
selectArry.push(item);
});
this.selectArry = selectArry;
var results = queryString ? selectArry.filter(this.createFilter(queryString)) : selectArry;
// 调用 callback 返回建议列表的数据
cb(results);
},
handleSelect(item) {
this.upkeepForm.branchCompanyId = item.id;
console.log(item);
},
createFilter(queryString) {
return (restaurant) => {
return (restaurant.name.indexOf(queryString.toLowerCase()) != -1);
};
},
getTypeName: function(type) {
if (this.$utils.isEmpty(this.vehicleWarningMsgType[type])) {
return '未知';
}
return this.vehicleWarningMsgType[type].val;
},
getValue(e){
this.listQuery.addrCity = undefined;
},
/**
* 确定
* */
okHandler(formName) {
const set = this.$refs;
if(!this.listQuery.addrProvince){
this.$notify({
title: '请选择省份',
message: '操作失败!',
type: 'error',
duration: 2000
});
return;
}
if(!this.listQuery.addrCity){
this.$notify({
title: '请选择城市',
message:'操作失败!',
type: 'error',
duration: 2000
});
return;
}
this.form.province = this.listQuery.addrProvince;
this.form.city = this.listQuery.addrCity;
set[formName].validate(valid => {
if (valid) {
this.$emit(this.form.eventName, this.form);
} else {
return;
}
});
},
/**
* 加载地图
* */
handler({map}){
},
//点击获取到当前经纬度
getClickInfo(e) {
console.log(e.point.lng);
console.log(e.point.lat);
this.form.longitude = e.point.lng;
this.form.latitude = e.point.lat;
},
//双向绑定经纬度以及缩放尺寸
syncCenterAndZoom(e) {
const { lng, lat } = e.target.getCenter();
this.form.longitude = lng;
this.form.latitude = lat;
// this.zoom = e.target.getZoom();
},
//经纬度同步
baidumap(){
this.baiduDevicelocationx = this.form.longitude
this.baiduDevicelocationy = this.form.latitude
},
/**
* 弹框-取消
* */
cancel() {
this.$emit(this.form.eventName, false);
this.cleanForm();
},
/**
* 清空弹框数据
*/
cleanForm() {
this.form = {
showTitle: "",//弹框名称
name: undefined,//地址名称
keyword:"",//根据关键词查找经纬度
address:undefined,//详细地址
longitude: undefined,
latitude:undefined,
eventName: undefined
};
this.listQuery = {
addrProvince: undefined,
addrCity: undefined,
}
},
getPoint(e){ //点击地图获取一些信息,
this.show = true;
this.postionMap.lng = e.point.lng; //通过 e.point.lng获取经度
this.postionMap.lat = e.point.lat; //通过 e.point.lat获取纬度
this.add.jd = e.point.lng;
this.add.wd = e.point.lat;
this.zoom = e.target.getZoom();
let geocoder= new BMap.Geocoder(); //创建地址解析器的实例
geocoder.getLocation(e.point,rs=>{
this.add.site = rs.address;
this.keyword = rs.address;
this.form.latitude = rs.point.lat;
this.form.longitude = rs.point.lng;
//地址描述(string)=
// console.log(rs.address); //这里打印可以看到里面的详细地址信息,可以根据需求选择想要的
// console.log(rs.addressComponents);//结构化的地址描述(object)
console.log(rs.addressComponents.province); //省
console.log(rs.addressComponents.city); //城市
console.log(rs.addressComponents.district); //区县
console.log(rs.addressComponents.street); //街道
console.log(rs.addressComponents.streetNumber); //门牌号
// console.log(rs.surroundingPois); //附近的POI点(array)
// console.log(rs.business); //商圈字段,代表此点所属的商圈(string)
});
},
infoWindowClose () {
this.show = false
},
infoWindowOpen () {
//这里有个问题纠结了很久,百度的信息窗口默认有个点击其他地方就消失的事件,我没有找到
//并且信息窗口点击一次显示,一次消失
//于是我加了一个100毫秒的定时器,保证每次点击地图都可以展示信息窗口
setInterval(()=>{
this.show = true
},100)
},
}
}
</script>
<style scoped>
.map {
width: 100%;
height: 500px;
}
.bm-info input[type="button"]{
width: 30px;
}
</style>
<template>
<!-- 旅游:创建、编辑 -->
<div>
<h4>{{title}}</h4>
<el-form :model="form" :rules="rules" ref="form" label-width="90px">
<el-row>
<el-col :span="8">
<el-form-item label="旅行名称">
<el-input v-model="form.name" placeholder="请输入旅行名称"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="描述">
<el-input v-model="form.describe" placeholder="请输入描述"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="旅行原价" prop="operator">
<el-input v-model="form.price" type="number" min="0" placeholder="请输入旅行原价"></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="儿童价" prop="operator">
<el-input v-model="form.childPrice" type="number" min="0" placeholder="请输入儿童价"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="会员价格" prop="mileage">
<el-radio class="radio" v-model="form.isMember" label="1">启用会员价</el-radio>
<el-radio class="radio" v-model="form.isMember" label="0">不启用会员价</el-radio>
</el-form-item>
<el-row>
<el-col :span="4">
<el-form-item label="库存" prop="amount">
<el-input v-model="form.stock" placeholder="请输入总人数" type="number" min="0"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<!--<el-col :span="24">-->
<el-form-item label="出发地" prop="departure">
<el-input style="display: inline-block;margin-right: 10px;width: 240px;" v-model="item.name" v-for="item in departureList"
:key="item.id" readonly placeholder="请输入内容" :on-icon-click="deleteDeparture"></el-input>
<el-button size="small" class="el-button el-button--primary" type="button" icon="edit" @click="editDeparture(departureList)">编辑</el-button>
<!--<el-autocomplete-->
<!--v-for="item in departureList"-->
<!--:key="item.id"-->
<!--class="inline-input"-->
<!--style="margin-left: 10px;"-->
<!--v-model="item.name"-->
<!--:fetch-suggestions="querySearch"-->
<!--placeholder="请输入内容"-->
<!--@select="handleSelect"-->
<!--&gt;</el-autocomplete>-->
</el-form-item>
<!--</el-col>-->
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="目的地">
<el-input v-model="destinationObj.address" readonly placeholder="请选择目的地" :on-icon-click="selectDestination" icon="edit"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<!--<el-col :span="6">-->
<el-form-item label="途径地">
<!--<el-input v-for="item in pathway" style="display: inline-block;margin-right: 10px;width: 240px;"-->
<!--:key="item.id" v-model="item.name" readonly placeholder="请选择途径地" :data-rowId="item.id" :on-icon-click="selectPathway" icon="edit"></el-input>-->
<el-button v-for="item in pathway"
:key="item.id" size="small" class="el-button el-button--primary" type="button" @click="editPathway(item)">{{item.name}}<i class="el-icon-edit el-icon--right"></i></el-button>
<el-button size="small" class="el-button el-button--primary" type="button" icon="plus" @click="addPathway()">添加</el-button>
</el-form-item>
<!--</el-col>-->
</el-row>
<el-row>
<el-form-item prop="operator" label="活动日期">
<!--tourDepartTimeVo-->
<el-button v-for="item in form.tourDepartTimeVo" disabled
:key="item.id" class="el-button el-button--default" type="button">{{item.startTime}}~{{item.endTime}}</el-button>
<el-button size="small" class="el-button el-button--primary" type="button" icon="edit" @click="editTime()">编辑</el-button>
<!--<el-input v-model="form.operator" placeholder="请选择活动日期"></el-input>-->
</el-form-item>
</el-row>
<el-form-item label="旅行标签" prop="approvers">
<span v-for="item in form.tagDTOS"
:key="item.id" style="border: 1px solid #ccc; padding: 5px 10px;border-radius: 5px;margin-right: 10px;">{{item.name}}</span>
<!--<el-checkbox-group v-model="checkList">-->
<!--<el-checkbox v-for="item in allLabelList"-->
<!--:key="item.id" :label="item.name"></el-checkbox>-->
<!--</el-checkbox-group>-->
<el-button size="small" class="el-button el-button--primary" type="button" icon="edit" @click="editLable(form.tagDTOS)">编辑</el-button>
</el-form-item>
<el-row>
<el-col :span="4">
<el-form-item label="浏览量">
<el-input v-model="form.viewCount" placeholder="请输入浏览量" type="number" min="0"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="排序">
<el-input v-model="form.rank" placeholder="请输入排序值" type="number" min="0"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="单位" prop="amount">
<el-input v-model="form.unit" placeholder="元/人"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="销量" prop="saleCount">
<el-input v-model="form.saleCount" type="number" min="0" placeholder="请输入销量"></el-input>
</el-form-item>
</el-col>
</el-row>
<!--BASE_API + -->
<el-form-item label="封面图" :style="{display:'block'}">
<el-upload
class="upload-demo"
:headers="getHeaderWithToken"
action="https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
list-type="picture">
<img v-if="$utils.isString(form.cover) && !$utils.isEmpty(form.cover)" :src="form.cover" style="width:300px;max-height:300px;">
</el-upload>
<!--<el-dialog v-model="dialogVisible" size="tiny">-->
<!--<img width="100%" :src="form.cover" alt="">-->
<!--</el-dialog>-->
</el-form-item>
<el-form-item label="轮播图" :style="{display:'block'}">
<el-upload
class="upload-demo"
:headers="getHeaderWithToken"
action="https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload"
:on-remove="handleRemove"
:file-list="fileList2"
:on-success="handleBannerSuccess"
list-type="picture">
<div slot="tip" class="el-upload__tip">最多上传5张</div>
<el-button v-if="fileList2.length<5" size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
<el-tabs v-model="activeName2" type="card" @tab-click="handleClick">
<el-tab-pane label="行程亮点" name="first">
<Editor v-if="activeName2=='first'" @input="handelContentIncrease" :value="form.content" :myQuillEditor="'myQuillEditorContent'" :activeName2="activeName2"></Editor>
</el-tab-pane>
<el-tab-pane label="行程介绍" name="second">
<Editor v-if="activeName2=='second'" @input="handelIntroduceIncrease" :value="form.introduce" :myQuillEditor="'myQuillEditorIntroduce'" :activeName2="activeName2"></Editor>
</el-tab-pane>
<el-tab-pane label="费用说明" name="third">
<Editor v-if="activeName2=='third'" @input="handelExplainIncrease" :value="form.explain" :myQuillEditor="'myQuillEditorExplain'" :activeName2="activeName2"></Editor>
</el-tab-pane>
</el-tabs>
<el-form-item></el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelTour">取 消</el-button>
<el-button type="primary" v-if="title=='创建'" @click="create()">确 定</el-button>
<el-button type="primary" v-if="title=='编辑'" @click="update()">确 定</el-button>
</div>
<!--编辑出发地-->
<departureModal v-if="editDepartureVisible" :list="departureList" v-on:departureEvent = "departureEvent"></departureModal>
<!--编辑目的地-->
<destination v-if="showDestinationVisible" :obj="destinationObj" v-on:destinationEvent = "destinationEvent"></destination>
<!--编辑途径地-->
<destination v-if="showPathWayVisible" :obj="onePathObj" v-on:pathWayEvent = "pathWayEvent"></destination>
<!--编辑活动时间-->
<tourTime v-if="showTimeVisible" :list="form.tourDepartTimeVo" :number="form.number" v-on:tourDepartTimeEvent = "tourDepartTimeEvent"></tourTime>
<!--编辑旅游标签-->
<tourLabelModal v-if="editLableVisible" :allLabelList="allLabelList" :checkList="checkList" v-on:tourLabelEvent = "tourLabelEvent"></tourLabelModal>
</div>
</template>
<style>
.el-upload-list{
display: flex;
width: 100px;
}
.el-upload-list li{
margin-left: 10px;
}
</style>
<script>
import Editor from "../../modal/editorTool";//富文本
import Destination from "./destinationModal";//目的地弹框
import tourTime from "./tourTime";//活动时间
import tourLabelModal from "./tourLabelModal";//旅游标签
import departureModal from "./departureModal";//出发地弹框
import {
page,
goodsEdit,
getOneGoodsById
} from 'api/tourManage';
import {
getAllUpkeepItem
} from 'api/vehicle/upkeep';
import rsCode from '../../../utils/rsCode';
import {
getToken
} from '../../../utils/auth';
import {mapGetters} from 'vuex';
import {
getAllCompany,
getAll
} from 'api/base_info/branch_company/';
import {
getTourTagList,
getAllTourTag
} from 'api/tourManage';
export default {
props: ["oneTourRow", "title"],
name: 'upkeepDialog',
components: {
Editor,
Destination,
tourTime,
tourLabelModal,
departureModal
},
data() {
return {
onePathObj:{name: ""},//待编辑的途径地
destinationObj:{name: ""},//目的地
departureList: [],//出发地列表
departureObj:{name: ""},//出发地
pathway: undefined,//途径地
fileList2:[],
activeName2: 'first',//行程亮点
form: {
childPrice: undefined,//儿童价
tourDepartVo:undefined,//type:0出发地 1途径地 2目的地
content: undefined,//行程亮点
cover:undefined,//封面图
describe: undefined,//描述
introduce: undefined,//行程介绍
crtTime: undefined,
explain: undefined,//费用说明
name: undefined,//旅行名称
price: undefined,//成人价
rank: undefined,
recommend: undefined,
saleCount: undefined,//初始销量
status: undefined,//0:未发布,1:上架 2:下架
stock: undefined,//总人数
unit: undefined,//单位
updTime: undefined,//更新时间
viewCount: undefined,//浏览量
isMember: undefined,//是否是会员商品
tagDTOS: undefined,//旅行标签
bannerDTOS:[],//banner轮播
},
showDestinationVisible: false,//编辑目的地
showPathWayVisible: false,//编辑途径地
showTimeVisible: false,//编辑时间
rules: {
name: [
{
type: 'string',
required: true,
message: '请输入消息内容',
trigger: 'blur'
},
{
min: 0,
max: 100,
message: '长度小于 100 个字符',
trigger: 'blur'
}
],
// departure: {
// type: 'string',
// required: true,
// message: '请输入出发地',
// trigger: 'blur'
// },
},
checkList:[],//已选中的标签
allCompanies: {},
allCompaniesArr: [],
oneTourDialogVisible: false,
editLableVisible: false,//旅游标签
editDepartureVisible: false,//出发地弹框
allUpkeepItems: null,
dialogStatus: undefined,
allLabelList: [],//全部旅游标签
}
},
created() {
getAll()
.then(response => {
this.allCompaniesArr = response.data;
})
getAllCompany(codeAndBranchCompany => {
this.allCompanies = codeAndBranchCompany;
});
this.getAllLabelList();
},
watch: {
oneTourDialogVisible(newValue, oldValue){
if(!newValue){
this.cleanForm();
}
},
},
mounted() {
let row = this.oneTourRow;
this.getOneGoods(row.id);
this.cleanForm();
this.oneTourDialogVisible = true;
},
computed: {
getHeaderWithToken() {
return {Authorization: getToken()};
},
},
methods: {
handleClick(tab, event) {
console.log(tab, event);
},
getWeek(week, name){
let weekStr = "";
switch (week) {
case 0:
weekStr = name + "天";
break;
case 1:
weekStr = name + "一";
break;
case 2:
weekStr = name + "二";
break;
case 3:
weekStr = name + "三";
break;
case 4:
weekStr = name + "四";
break;
case 5:
weekStr = name + "五";
break;
case 6:
weekStr = name + "六";
break;
}
return weekStr;
},
/**
* 编辑出发地
* */
editDeparture(list){
console.log(list);
this.editDepartureVisible = true;
},
/**
* 关闭出发地弹框
* */
departureEvent(obj){
this.editDepartureVisible = false;
if(obj){
this.departureList = obj;
console.log(obj);
}
},
/**
* 编辑旅游标签
* */
editLable(list){
console.log(list);
this.editLableVisible = true;
},
/**
* 创建
* */
create(){},
/**
* 编辑
* */
update(){
// {"name":"ssss","cover":"ssss","price":"500","childPrice":100,"viewCount":"100","saleCount":"100","describe":"225555","content":"235685","introduce":"sssss","explain":"dddss","rank":1,
// "recommend":1,"isMember":1,"stock":2,"unit":"元/个","number":2,
// "bannerDTOS":[
// {"cover":"ssssss"}, {"cover":"ssssss"}, {"cover":"ssssss"}
// ],
// "siteDTOS":[
// {"name":"ssssss","address":"ssssss","companyId":2,"province":1000,"provinceName":10002,"city":10001,"cityName":10002,"longitude":12.00000,"latitude":23.6552,"type":0,"rank":1},
// {"name":"ssssss","address":"ssssss","companyId":2,"province":1000,"provinceName":10002,"city":10001,"cityName":10002,"longitude":12.00000,"latitude":23.6552,"type":1,"rank":1},
// {"name":"ssssss","address":"ssssss","companyId":2,"province":1000,"provinceName":10002,"city":10001,"cityName":10002,"longitude":12.00000,"latitude":23.6552,"type":2,"rank":1}
// ],
// "priceDTOS":[
// {"startTime":"2019-06-01","endTime":"2019-06-03","stock":50},
// {"startTime":"2019-06-02","endTime":"2019-06-04","stock":50},
// {"startTime":"2019-06-03","endTime":"2019-06-05","stock":50}
// ],
// "tagDTOS":[
// {"tagId":1},
// {"tagId":2}
//
// ]
// }
//旅游标签
let tagDTOS = [];
this.form.tagDTOS.map(function(item){
tagDTOS.push({tagId: item.id});
});
//轮播图
let bannerDTOS = [];
this.form.bannerDTOS.map(function(item){
bannerDTOS.push({cover: item.cover});
});
let siteDTOS = [];
// {"name":"ssssss","address":"ssssss","companyId":2,"province":1000,"provinceName":10002,"city":10001,"cityName":10002,"longitude":12.00000,"latitude":23.6552,"type":0,"rank":1}
//出发地
this.departureList.map(function(item){
let p = {
name: item.p,
address: item.address,
companyId: item.companyId,
province: item.addrProvince,
city: item.addrCity,
longitude: item.longitude,
latitude: item.latitude,
type: 0,
rank: item.rank
};
item.type = 0;
siteDTOS.push(item);
});
//途径地
this.pathway.map(function(item){
item.type = 1;
siteDTOS.push(item);
});
//destinationObj目的地
siteDTOS.push(this.destinationObj);
let params = {
name: this.form.name,//旅游路线名称
cover: this.form.cover,//封面图
price: this.form.price,//成人价
childPrice: this.form.childPrice,//儿童价
viewCount: this.form.viewCount,//商品浏览量
saleCount: this.form.saleCount,//商品销售量
describe: this.form.describe,//商品描述
content: this.form.content,//商品详情(行程亮点)
introduce: this.form.introduce,//行程介绍
explain: this.form.explain,//费用说明
rank: this.form.rank,//旅行排序
recommend: this.form.recommend,//是否推荐:0-未推荐;1-已推荐
isMember: this.form.isMember,//是否启用会员价
stock: this.form.stock,//库存
unit: this.form.unit,//单位
number: this.form.number,//活动天数
bannerDTOS: bannerDTOS,//banner轮播图
siteDTOS: siteDTOS,//出发地type=0,途径地type=1,目的地type=2
priceDTOS: this.form.tourDepartTimeVo,//活动日期
tagDTOS: tagDTOS//旅游标签
};
console.log(params);
console.log(this.form);
goodsEdit(params).then(response => {
if (response.status === 200) {
this.$notify({
title: '成功',
message: '编辑成功',
type: 'success',
duration: 2000
});
this.$emit("oneTourDialogEvent", true);
} else {
this.$notify({
title: '编辑失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
},
/**
* 获取全部旅游标签
* */
getAllLabelList() {
getAllTourTag().then(response => {
this.allLabelList = response.data;
});
},
/**
* 关闭目的地弹框
* */
destinationEvent(obj){
this.showDestinationVisible = false;
if(obj){
this.destinationObj = obj;
console.log(obj);
}
},
/**
* 选择目的地
* */
selectDestination(){
let that = this;
this.destinationObj.showTitle = "目的地编辑";
this.destinationObj.headTitle = "目的地名称";
this.destinationObj.eventName ='destinationEvent';
this.destinationObj.keyword = this.destinationObj.address;
this.showDestinationVisible = true;
},
/**
* 关闭活动日期
* */
tourDepartTimeEvent(params){
this.showTimeVisible = false;
if(params){
this.form.number = params.num;
this.form.tourDepartTimeVo = params.priceDTOS;
console.log(params);
}
},
/**
* 关闭途径地弹框
* */
pathWayEvent(obj){debugger
this.showPathWayVisible = false;
if(obj){
if(obj.showTitle == "途径地编辑"){
if(obj.method == "delete"){
//删除当前路径
this.pathway.splice(obj, 1);
} else {
this.onePathObj = obj;
}
} else {
this.pathway.push(obj);
}
console.log(obj);
}
},
/**
* 编辑一条途径地数据
* */
selectPathway(obj){
let that = this;
console.log(obj);
this.onePathObj = obj;
this.onePathObj.showTitle = "途径地编辑";
this.onePathObj.headTitle = "途径地名称";
},
/**
* 关闭旅游标签弹框
* */
tourLabelEvent(obj){
let that = this;
this.editLableVisible = false;
let arr = [];
let ckeckList = [];
if(obj){
this.allLabelList.map(function(item){
obj.map(function(b){
if(item.name == b){
arr.push(item);
ckeckList.push(b);
}
});
});
this.form.tagDTOS = arr;
this.checkList = ckeckList;
console.log(obj);
}
},
/**
* 编辑一条途径地
**/
editPathway(item){debugger
this.onePathObj = item;
this.onePathObj.showTitle = "途径地编辑";//弹框名称
this.onePathObj.headTitle = "途径地名称";
this.onePathObj.keyword = item.address,//根据关键词查找经纬度
this.onePathObj.eventName = "pathWayEvent";
this.showPathWayVisible = true;
},
/**
* 添加途径地
* */
addPathway(){
let that = this;
this.onePathObj = {
showTitle: "途径地添加",//弹框名称
headTitle: "途径地名称",
name: undefined,//地址名称
keyword:"东莞市",//根据关键词查找经纬度
address:undefined,//详细地址
longitude: 113.758993,
latitude:23.031565,
eventName: "pathWayEvent"
};
this.showPathWayVisible = true;
},
/**
* 添加时间
* */
editTime(){
this.showTimeVisible = true;
},
/**
* 获取一条旅游路线
* */
getOneGoods(id){
let params = {
id: id
};
let that = this;
getOneGoodsById(params).then(response => {
that.pathway = [];
response.data.tourDepartVo.map(function(item){
if(item.type == 0){
//出发地
that.departureList.push(item);
}
if(item.type == 2 && that.destinationObj.name == ""){
//目的地
that.destinationObj = item;
}
if(item.type==1){
//途径地
that.pathway.push(item);
}
});
let arr = [];
this.form = response.data;
this.allLabelList.map(function(b){
response.data.tagDTOS.map(function(item){
if(item.id == b.id){
arr.push(item.name);
}
});
});
this.checkList = arr;
//轮播
let fileList2 = [];
response.data.bannerDTOS.map(function(item){
let p = {
url: item.cover
};
fileList2.push(p);
});
this.fileList2 = fileList2;
this.form.isMember = this.form.isMember+"";
})
},
querySearch(queryString, cb) {
let selectArry = [];
this.allCompaniesArr.map(function(item){
item.value = item.name;
selectArry.push(item);
});
this.selectArry = selectArry;
var results = queryString ? selectArry.filter(this.createFilter(queryString)) : selectArry;
// 调用 callback 返回建议列表的数据
cb(results);
},
handleSelect(item) {
this.departureObj = item;
console.log(item);
},
createFilter(queryString) {
return (restaurant) => {
return (restaurant.name.indexOf(queryString.toLowerCase()) != -1);
};
},
/**
* 旅游-弹框-取消
* */
cancelTour() {
this.cleanForm();
this.$emit("oneTourDialogEvent", false);
},
/**
* 富文本内容 费用说明
* @param step
*/
handelExplainIncrease(step) {
this.form.explain = step;
},
/**
* 行程介绍 富文本
* */
handelIntroduceIncrease(step){
this.form.introduce = step;
},
/**
* 富文本 content行程亮点
* */
handelContentIncrease(step){
this.form.content = step;
},
/**
* 删除banner
* */
handleRemove(file, fileList){
let list = [];
fileList.map(function(item){
if(item.url != file.url){
list.push(item);
}
});
this.fileList2 = list;
let arr = [];
this.form.bannerDTOS.map(function(item){
if(item.cover != file.url){
arr.push(item);
}
});
this.form.bannerDTOS = arr;
},
/**
* 封面图上传
* **/
handleAvatarSuccess(res, file){debugger
this.form.cover = res.data;
},
/**
* banner上传
* */
handleBannerSuccess(res, file){
this.fileList2.push({url:res.data});
this.form.bannerDTOS.push({cover:res.data});
},
/**
* 清空旅游弹框数据
*/
cleanForm() {
this.form = {
bannerDTOS:[],
value11: "",
radio: "1",
vehicleId: null,
numberPlate: null,
operator: null,
date: null,
mileage: null,
amount: null,
approvers: null,
branchCompanyId: null
}
}
}
}
</script>
<template>
<el-dialog title="旅游标签" :visible.sync="isVisible">
<el-checkbox-group v-model="list">
<el-checkbox v-for="item in allLabelList"
:key="item.id" :label="item.name"></el-checkbox>
</el-checkbox-group>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="okHandler()">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
props: ["allLabelList", "checkList"],
name: 'tourLabelModal',
data() {
return {
isVisible: false,
list: "",
}
},
created() {
},
watch: {
isVisible(newValue, oldValue){
if(!newValue){
this.$emit('tourLabelEvent', false);
}
}
},
mounted() {
let that = this;
this.list = this.checkList;
this.isVisible = true;
},
methods: {
/**
* 确定
* */
okHandler() {
this.$emit('tourLabelEvent', this.list);
},
/**
* 弹框-取消
* */
cancel() {
this.$emit('tourLabelEvent', false);
},
}
}
</script>
<template>
<el-dialog title="活动日期" :visible.sync="isVisible">
<el-button size="small" class="el-button el-button--primary" type="button" icon="plus" @click="addTime()">添加</el-button>
<el-form>
<el-row>
<el-col :span="24">
<el-form-item label="活动天数">
<el-input style="width: 200px;" v-model="num" type="number" min="1" placeholder="请输入活动天数" @change="changeNum()"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row v-for="item in list"
style="margin: 10px 0;"
:key="item.id">
<el-col :span="8">
<el-form-item label="开始时间">
<el-date-picker
v-model="item.startTime"
type="date"
@change="changeStartTime(item)"
format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="结束时间">
<el-date-picker
disabled
v-model="item.endTime"
type="date"
format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="库存">
<el-input style="width: 150px;" v-model="item.stock" placeholder="请输入库存"></el-input>
<el-button type="danger" size="small" @click="deleteItem(item)">删除</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="okHandler('form')">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
import {
getSonRegionByCodes,
getRegionByCodes,
} from 'api/base_info/region/';
import rsCode from '../../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
formatDate
} from 'utils/dateFormattor';
import {
getAllCompany,
getAll
} from 'api/base_info/branch_company/';
import ElRow from "element-ui/packages/row/src/row";
import ElInput from "../../../../node_modules/element-ui/packages/input/src/input.vue";
import ElCol from "element-ui/packages/col/src/col";
import ElFormItem from "../../../../node_modules/element-ui/packages/form/src/form-item.vue";
import ElForm from "../../../../node_modules/element-ui/packages/form/src/form.vue";
export default {
props: ["list", "number"],
name: 'destinationDialog',
components: {
ElForm,
ElFormItem,
ElCol,
ElInput,
ElRow
},
data() {
return {
isVisible: false,
time:"",
lists: [],
t: {},
num: 0
}
},
created() {
},
watch: {
isVisible(newValue, oldValue){
if(!newValue){
this.$emit('tourDepartTimeEvent', false);
}
},
},
mounted() {
let that = this;
this.num = this.number;
this.list.map(function(item){
let arr = [];
arr.push(item.startTime);
arr.push(item.endTime);
item.visible2 = false;
item.time = arr;
});
// this.lists = this.list;
this.isVisible = true;
},
computed: {
...mapGetters([
'elements',
])
},
methods: {
/**
* 删除时间
* */
deleteItem(obj){
this.list.splice(this.list.indexOf(obj),1);
console.log(obj);
},
deleteHandler(){},
addTime(){
this.t = {
startTime:"",
endTime: "",
stock: 0
};
this.list.push(this.t);
},
/**
* 确定
* */
okHandler() {
if(this.num*1<=0){
this.$notify({
title: '失败',
message: '活动时间必须大于0',
type: 'warning',
duration: 2000
});
return false;
}
let arr = [];
this.list.map(function(item){
let t = {
startTime: item.startTime,
endTime: item.endTime,
stock: item.stock
};
arr.push(t);
});
let params = {
priceDTOS: arr,
num: this.num*1
};
this.$emit('tourDepartTimeEvent', params);
console.log(params)
},
/**
* 弹框-取消
* */
cancel() {
this.$emit('tourDepartTimeEvent', false);
},
dateChange1(val) { this.filters.startDate = val; },
/**
* 改变时间
* */
changeStartTime(d){
if(this.num<=0){
this.$notify({
title: '失败',
message: '活动时间必须大于0',
type: 'warning',
duration: 2000
});
return false;
} else {
}
d.endTime = formatDate(new Date(d.startTime.getTime() + 3600 * 1000 * 24 * this.num), 'yyyy-MM-dd');
d.startTime = formatDate(d.startTime, 'yyyy-MM-dd');
},
/**
* 改变活动天数-重新计算结束时间
* */
changeNum(){
console.log(this.num);
let that = this;
this.num = this.num*1;
if(this.num>0){
this.list.map(function(item){
let t = new Date(new Date(item.startTime).getTime() + 3600 * 1000 * 24 * that.num);
item.startTime = formatDate(new Date(item.startTime), 'yyyy-MM-dd');
item.endTime = formatDate(t, 'yyyy-MM-dd');
});
console.log(this.list);
}
}
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment