|
@@ -12,7 +12,6 @@
|
|
|
<el-col :span="24">
|
|
|
<vxe-table
|
|
|
border
|
|
|
- :footer-method="footerMethod2"
|
|
|
show-overflow
|
|
|
show-footer
|
|
|
ref="baseTable"
|
|
@@ -25,7 +24,6 @@
|
|
|
keep-source
|
|
|
:readonly="true"
|
|
|
highlight-current-row
|
|
|
- :edit-rules="tableRules"
|
|
|
:edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true, icon: '-'}"
|
|
|
>
|
|
|
<vxe-table-column field="name" align="center" title="项目名称" :edit-render="{}" show-overflow="title">
|
|
@@ -73,8 +71,9 @@
|
|
|
:rules="[
|
|
|
{required: true, message:'用车起止时间不能为空', trigger:'blur'}]">
|
|
|
<el-date-picker
|
|
|
+ :disabled-date="getDisabledData"
|
|
|
v-model="inputForm.useDate"
|
|
|
- type="datetimerange"
|
|
|
+ type="daterange"
|
|
|
start-placeholder="请选择开始时间"
|
|
|
end-placeholder="请选择结束时间"
|
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
@@ -113,6 +112,7 @@
|
|
|
import UserSelectSignatory from './clientUserSelect'
|
|
|
import UpLoadComponent from '@/views/common/UpLoadComponent'
|
|
|
import CommonApi from '@/api/cw/common/CommonApi'
|
|
|
+ import moment from "moment";
|
|
|
export default {
|
|
|
props: {
|
|
|
businessId: {
|
|
@@ -149,6 +149,7 @@
|
|
|
keyWatch: '',
|
|
|
dateList:[],
|
|
|
programRow:'',
|
|
|
+ disabledDates:[],
|
|
|
|
|
|
}
|
|
|
},
|
|
@@ -182,10 +183,8 @@
|
|
|
watch: {
|
|
|
'keyWatch': {
|
|
|
handler (newVal) {
|
|
|
- if (this.bus) {
|
|
|
- if (this.bus !== 'false') {
|
|
|
- this.init('', this.bus)
|
|
|
- }
|
|
|
+ if (this.commonJS.isNotEmpty(this.bus)) {
|
|
|
+ this.init('', this.bus)
|
|
|
} else {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.inputForm.resetFields()
|
|
@@ -222,24 +221,23 @@
|
|
|
this.$refs.inputForm.resetFields()
|
|
|
this.loading = true
|
|
|
this.$refs.uploadComponent.clearUpload()
|
|
|
- if (this.commonJS.isNotEmpty(this.inputForm.id)) {
|
|
|
- console.log('this.inputForm.id', this.inputForm.id)
|
|
|
- this.driveService.queryById(this.inputForm.id).then((data)=>{
|
|
|
- this.inputForm = this.recover(this.inputForm, data)
|
|
|
- this.inputForm.files=data.files
|
|
|
- console.log('s',this.inputForm)
|
|
|
- if (this.status === 'audit' || this.status === 'taskFormDetail') {
|
|
|
- method = 'view'
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.projectList)) {
|
|
|
- this.inputForm.projectList=[]
|
|
|
- }
|
|
|
- console.log('me',method)
|
|
|
- this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'driveApply',null,null,null,null,null)
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
+ this.driveService.queryById(this.inputForm.id).then((data)=>{
|
|
|
+ this.inputForm = this.recover(this.inputForm, data)
|
|
|
+ this.inputForm.files=data.files
|
|
|
+ console.log('s',this.inputForm)
|
|
|
+ if (this.status === 'audit' || this.status === 'taskFormDetail') {
|
|
|
+ method = 'view'
|
|
|
+ }
|
|
|
+ if (this.commonJS.isEmpty(this.inputForm.projectList)) {
|
|
|
+ this.inputForm.projectList=[]
|
|
|
+ }
|
|
|
+ console.log('me',method)
|
|
|
+ this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'driveApply',null,null,null,null,null)
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ this.driveService.getUserTime().then((data)=>{
|
|
|
+ this.disabledDates = data
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
saveForm(callback) {
|
|
@@ -326,29 +324,7 @@
|
|
|
})
|
|
|
return
|
|
|
} else if (status === 'start') {
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.projectList)) {
|
|
|
- this.loading = false
|
|
|
- this.$message.error('请选择用车项目')
|
|
|
- throw new Error()
|
|
|
- }
|
|
|
- if (this.inputForm.useDate == undefined ||this.inputForm.useDate == null || this.inputForm.useDate.length <= 0 ) {
|
|
|
- this.$message.error('请选择用车时间')
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.useMen)){
|
|
|
- this.$message.error('请选择用车人员')
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- if (this.commonJS.isEmpty(this.inputForm.useReason)){
|
|
|
- this.$message.error('请选择用车原因')
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- this.inputForm.useStartTime=this.inputForm.useDate[0]
|
|
|
- this.inputForm.useEndTime=this.inputForm.useDate[1]
|
|
|
- if (this.$refs.uploadComponent.checkProgress()) {
|
|
|
- this.loading = false
|
|
|
- return
|
|
|
- }
|
|
|
+
|
|
|
this.inputForm.files = this.$refs.uploadComponent.getDataList()
|
|
|
// 送审 待审核
|
|
|
this.inputForm.status = '2'
|
|
@@ -360,22 +336,56 @@
|
|
|
this.$refs['inputForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
this.loading = true
|
|
|
+ if (this.commonJS.isEmpty(this.inputForm.projectList)) {
|
|
|
+ this.loading = false
|
|
|
+ this.$message.error('请选择用车项目')
|
|
|
+ throw new Error()
|
|
|
+ }
|
|
|
+ if (this.inputForm.useDate == undefined ||this.inputForm.useDate == null || this.inputForm.useDate.length <= 0 ) {
|
|
|
+ this.$message.error('请选择用车时间')
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ if (this.commonJS.isEmpty(this.inputForm.useMen)){
|
|
|
+ this.$message.error('请选择用车人员')
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ if (this.commonJS.isEmpty(this.inputForm.useReason)){
|
|
|
+ this.$message.error('请选择用车原因')
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.$refs.uploadComponent.checkProgress()) {
|
|
|
+ this.loading = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.inputForm.useStartTime=this.inputForm.useDate[0]
|
|
|
+ this.inputForm.useEndTime=this.inputForm.useDate[1]
|
|
|
console.log('form',this.inputForm)
|
|
|
- if (this.commonJS.isNotEmpty(this.inputForm.useMen)) {
|
|
|
- this.driveService.checkUseMen(this.inputForm.useMen).then((data)=>{
|
|
|
- if (data === false){
|
|
|
- this.$message.error('只能选择本部门员工')
|
|
|
+ if (this.commonJS.isNotEmpty(this.inputForm.useStartTime) && this.commonJS.isNotEmpty(this.inputForm.useEndTime)){
|
|
|
+ this.driveService.checkTimeRange(this.inputForm.useStartTime,this.inputForm.useEndTime).then((data)=>{
|
|
|
+ if (data){
|
|
|
this.loading = false
|
|
|
- return
|
|
|
+ this.$message.error('用车时间存在重叠,请重新选择时间')
|
|
|
+ throw new Error()
|
|
|
+ }else {
|
|
|
+ if (this.commonJS.isNotEmpty(this.inputForm.useMen)) {
|
|
|
+ this.driveService.checkUseMen(this.inputForm.useMen).then((data) => {
|
|
|
+ if (data === false) {
|
|
|
+ this.$message.error('只能选择本部门员工')
|
|
|
+ this.loading = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.driveService.saveForm(this.inputForm).then((data) => {
|
|
|
+ callback(data.businessTable, data.businessId, this.inputForm)
|
|
|
+ this.$refs.inputForm.resetFields()
|
|
|
+ this.loading = false
|
|
|
+ }).catch(() => {
|
|
|
+ this.$refs.inputForm.resetFields()
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- this.driveService.saveForm(this.inputForm).then((data) => {
|
|
|
- callback(data.businessTable, data.businessId, this.inputForm)
|
|
|
- this.$refs.inputForm.resetFields()
|
|
|
- this.loading = false
|
|
|
- }).catch(() => {
|
|
|
- this.$refs.inputForm.resetFields()
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
@@ -506,6 +516,40 @@
|
|
|
this.programRow = ''
|
|
|
// this.inputForm.reconciliationArea = this.inputForm.financeInvoiceBaseDTOList[0].location
|
|
|
},
|
|
|
+ //获取需要禁用时间
|
|
|
+ getDisabledData(time) {
|
|
|
+
|
|
|
+ // if (time.getTime() < Date.now() - 24 * 3600 * 1000){
|
|
|
+ // return true
|
|
|
+ // }
|
|
|
+ // 检查给定的时间是否在禁用时间范围内
|
|
|
+ for (let i = 0; i < this.disabledDates.length; i++) {
|
|
|
+ const startTime = moment(this.disabledDates[i].startTime).startOf('day');
|
|
|
+ const endTime = moment(this.disabledDates[i].endTime).endOf('day');
|
|
|
+ const timeMoment = moment(time);
|
|
|
+ console.log('startTime',startTime.valueOf())
|
|
|
+ console.log('endTime',endTime.valueOf())
|
|
|
+ console.log('time.getTime()',time.getTime())
|
|
|
+ if (timeMoment.isBetween(startTime, endTime, null, '[]') || time.getTime() < Date.now() - 24 * 3600 * 1000) {
|
|
|
+ return true; // 如果在给定的禁用时间范围内,返回 true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果没有在禁用时间范围内,则检查是否在过去(不包括今天)
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+
|
|
|
+ //校验时间
|
|
|
+ checkTimeRange(){
|
|
|
+ this.loading = true
|
|
|
+ this.inputForm.useStartTime=this.inputForm.useDate[0]
|
|
|
+ this.inputForm.useEndTime=this.inputForm.useDate[1]
|
|
|
+ this.driveService.checkTimeRange(this.inputForm.useStartTime,this.inputForm.useEndTime).then((data)=>{
|
|
|
+ this.loading = false
|
|
|
+ this.$message.error(data)
|
|
|
+ return
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|