scorpio 2 жил өмнө
parent
commit
adddf79b22

+ 33 - 20
src/views/home/component/owner_serach.vue

@@ -180,14 +180,14 @@
 
 <script>
 import baseButton from '../../../components/base-button.vue'
-import {useStore} from '@/store/user.js'
+import { useStore } from '@/store/user.js'
 
 export default {
   name: 'owner_serach',
-  components: {baseButton},
+  components: { baseButton },
   watch: {
     keyWords: {
-      handler(val) {
+      handler (val) {
         setTimeout(() => {
           this.change()
         }, 500)
@@ -195,11 +195,11 @@ export default {
       immediate: true
     }
   },
-  setup() {
+  setup () {
     const user = useStore()
-    return {user}
+    return { user }
   },
-  data() {
+  data () {
     return {
       deptList: [],
       form: {
@@ -275,18 +275,25 @@ export default {
       time2: null // 计划 实际入库时间
     }
   },
-  created() {
+  created () {
     this.getTypeList()
   },
   methods: {
-    getTypeList() {
+    getTypeList () {
       this.$api.project.typeList().then(res => {
         this.typeList = res.data.records
       })
     },
-    sure() {
+    sure () {
       this.form.type = true
-      if (this.form.isStart === 0 && this.time1 !== null) {
+      if (this.time1 !== null && this.form.isStart.length === 0) {
+        this.$message.error('请先选择是否开工')
+        return
+      } else if (this.time2 !== null && this.form.isStorage.length === 0) {
+        this.$message.error('请先选择是否入库')
+        return
+      }
+      if (this.form.isStart === 0) {
         this.form.planCommencementTime = this.time1
         this.form.startTime = ''
       } else if (this.form.isStart === 1 && this.time1 !== null) {
@@ -297,10 +304,10 @@ export default {
         this.form.startTime = ''
       }
 
-      if (this.form.isStorage === 0 && this.time2 !== null) {
+      if (this.form.isStorage === 0 ) {
         this.form.planStorageTime = this.time2
         this.form.storageTime = ''
-      } else if (this.form.isStorage === 1 && this.time2 !== null) {
+      } else if (this.form.isStorage === 1 ) {
         this.form.planStorageTime = ''
         this.form.storageTime = this.time2
       } else {
@@ -309,7 +316,7 @@ export default {
       }
       this.$bus.emit('serach', this.form)
     },
-    visibleTime(event, type) {
+    visibleTime (event, type) {
       if (event) {
         console.log(this.form.isStart)
         if (type === 1) {
@@ -325,7 +332,7 @@ export default {
         }
       }
     },
-    clear() {
+    clear () {
       this.form.projectName = ''
       this.form.typeId = ''
       this.form.isStorage = ''
@@ -335,17 +342,23 @@ export default {
       this.form.isImportant = ''
       this.form.deptIds = ''
       this.form.type = false
+      this.form.planCommencementTime = ''
+      this.form.startTime = ''
+      this.form.planStorageTime = ''
+      this.form.storageTime = ''
+      this.time1 = null
+      this.time2 = null
       this.$bus.emit('serach', this.form)
     },
-    changeAmount() {
+    changeAmount () {
       const tmps = this.form.amount.split(',')
       console.log(tmps)
       this.form.totalAmountMin = tmps[0] === '-' ? '' : tmps[0]
       this.form.totalAmountMax = tmps[1] === '-' ? '' : tmps[1]
     },
-    getOrg() {
+    getOrg () {
       const parentId = [0, 2].includes(this.user.info.viewStage) ? this.user.info.parentDeptId : this.user.info.deptId
-      this.$api.system.getDeptLazy({parentId}).then(res => {
+      this.$api.system.getDeptLazy({ parentId }).then(res => {
         if (res.code === 200) {
           this.showOrg = true
           this.deptList = res.data.map(e => {
@@ -357,15 +370,15 @@ export default {
         }
       })
     },
-    changeChecked(index) {
+    changeChecked (index) {
       this.deptList[index].checked = !this.deptList[index].checked
     },
-    orgCheck() {
+    orgCheck () {
       const checked = this.deptList.filter(sub => sub.checked)
       this.form.deptIds = checked.map(sub => sub.id).join(',')
       this.showOrg = false
     },
-    change() {
+    change () {
       if (this.keyWords.length === 0) {
         this.deptList.forEach(sub => sub.search = false)
         return