owner_serach.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <div class="flex flex-center padding white-bg ">
  3. <el-form v-model="form" class="lab mt-20 full-width" label-width="160px">
  4. <div class="flex">
  5. <div class="flex flex-col mr-15">
  6. <el-form-item class="full-width" label="项目名称">
  7. <el-input
  8. v-model="form.projectName"
  9. placeholder="输入项目关键字"
  10. prefix-icon="Search"
  11. clearable
  12. />
  13. </el-form-item>
  14. <div class="flex flex-center">
  15. <el-form-item class="full-width" label="是否开工">
  16. <el-select
  17. v-model="form.isStart"
  18. style="width: 100%"
  19. clearable
  20. >
  21. <el-option
  22. v-for="item in start"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item class="full-width" label="是否入库">
  30. <el-select
  31. v-model="form.isStorage"
  32. style="width: 100%"
  33. clearable
  34. >
  35. <el-option
  36. v-for="item in storage"
  37. :key="item.value"
  38. :label="item.label"
  39. :value="item.value"
  40. />
  41. </el-select>
  42. </el-form-item>
  43. </div>
  44. <div>
  45. <el-form-item class="full-width" label="计划(实际)开工时间">
  46. <el-date-picker
  47. v-model="time1"
  48. type="daterange"
  49. @visible-change="visibleTime($event,1)"
  50. range-separator="至"
  51. start-placeholder="开始时间"
  52. end-placeholder="结束时间"
  53. value-format='YYYY-MM-DD'
  54. format='YYYY-MM-DD'
  55. clearable
  56. />
  57. </el-form-item>
  58. </div>
  59. </div>
  60. <div class="flex flex-col ml-20 mr-15">
  61. <!-- <el-form-item class="full-width" label="分类筛选">-->
  62. <!-- <el-select-->
  63. <!-- v-model="form.typeId"-->
  64. <!-- clearable-->
  65. <!-- placeholder="选择项目分类"-->
  66. <!-- style="width: 100%">-->
  67. <!-- <el-option-->
  68. <!-- v-for="item in typeList"-->
  69. <!-- :key="item.id"-->
  70. <!-- :label="item.name"-->
  71. <!-- :value="item.id"-->
  72. <!-- />-->
  73. <!-- </el-select>-->
  74. <!-- </el-form-item>-->
  75. <div class="flex flex-center ">
  76. <el-form-item class="full-width" label="省重点">
  77. <el-select
  78. v-model="form.isImportant"
  79. style="width: 100%"
  80. clearable
  81. >
  82. <el-option
  83. v-for="item in isimport"
  84. :key="item.value"
  85. :label="item.label"
  86. :value="item.value"
  87. />
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item class="full-width" label="省集中开工">
  91. <el-select
  92. v-model="form.isFocusStart"
  93. style="width: 100%"
  94. clearable
  95. >
  96. <el-option
  97. v-for="item in isfocus"
  98. :key="item.value"
  99. :label="item.label"
  100. :value="item.value"
  101. />
  102. </el-select>
  103. </el-form-item>
  104. </div>
  105. <div class="flex flex-center flex-justify-between">
  106. <el-form-item class="full-width " label="总投资额">
  107. <el-select
  108. v-model="form.amount"
  109. @change="changeAmount"
  110. style="width: 100%"
  111. clearable
  112. >
  113. <el-option
  114. v-for="item in totalAmount"
  115. :key="item.value"
  116. :label="item.name"
  117. :value="item.value"
  118. />
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item class="full-width" label="机构选择">
  122. <div class="grey-9 pointer chose-box nowrap" @click="getOrg">
  123. {{ deptName }}
  124. </div>
  125. </el-form-item>
  126. </div>
  127. <div class="flex flex-center flex-justify-end">
  128. </div>
  129. <div>
  130. <el-form-item class="full-width" label="计划(实际)入库时间">
  131. <el-date-picker
  132. v-model="time2"
  133. type="daterange"
  134. @visible-change="visibleTime($event,2)"
  135. range-separator="至"
  136. start-placeholder="开始时间"
  137. end-placeholder="结束时间"
  138. value-format='YYYY-MM-DD'
  139. format='YYYY-MM-DD'
  140. clearable
  141. />
  142. </el-form-item>
  143. </div>
  144. </div>
  145. <div class="flex flex-col flex-justify-between">
  146. <div></div>
  147. <div class="flex flex-align-center flex-justify-end ml-10" style="margin-bottom: 18px">
  148. <base-button class="pointer " icon="Delete" title="清空" type="0" width="130" @click="clear"/>
  149. <base-button class="pointer ml-20" width="130" @click="sure"/>
  150. </div>
  151. </div>
  152. </div>
  153. </el-form>
  154. <!----机构选择----->
  155. <el-dialog v-model='showOrg'
  156. append-to-body
  157. center
  158. title="机构选择"
  159. width="45%">
  160. <div class="flex flex-col">
  161. <el-input
  162. v-model="keyWords"
  163. clearable
  164. placeholder="机构快速搜索"
  165. prefix-icon="Search"
  166. @blur='change'
  167. />
  168. </div>
  169. <el-divider/>
  170. <div class="hide-scrollbar full-width" style="height: 40vh;overflow-x: scroll">
  171. <!-- <div v-if='attaches.length === 0' class='full-width flex flex-center '>-->
  172. <!-- <el-empty image-size='100'/>-->
  173. <!-- </div>-->
  174. <div class="flex flex-justify-between flex-center">
  175. <span class="bold font-15 grey ml-5 ">部门</span>
  176. </div>
  177. <div class="grid radius mt-15 padding" style="border: 1px solid #DDDFE6">
  178. <div v-for="(item,index) in deptList" :key='item.id' class="flex flex-center pointer padding"
  179. :class="item.search ? 'org-search' : item.checked ? 'org-s' : 'org'" @click='changeChecked(index)'>
  180. <div :class="item.checked ? 'dot-checked' : 'dot'"></div>
  181. <div class='ml-5 full-width' :class="item.checked || item.search ? 'white' : ''">{{ item.deptName }}</div>
  182. </div>
  183. </div>
  184. </div>
  185. <div class="flex flex-center mt-20 mb-5">
  186. <base-button title="重置" type="0" icon="Refresh"/>
  187. <base-button class="ml-20" title="确定" icon="Check" @click='orgCheck'/>
  188. </div>
  189. </el-dialog>
  190. </div>
  191. </template>
  192. <script>
  193. import baseButton from '../../../components/base-button.vue'
  194. import {useStore} from '@/store/user.js'
  195. export default {
  196. name: 'owner_serach',
  197. components: {baseButton},
  198. watch: {
  199. keyWords: {
  200. handler(val) {
  201. setTimeout(() => {
  202. this.change()
  203. }, 500)
  204. },
  205. immediate: true
  206. }
  207. },
  208. setup() {
  209. const user = useStore()
  210. return {user}
  211. },
  212. data() {
  213. return {
  214. deptList: [],
  215. form: {
  216. projectName: '', // 项目名称/关键字
  217. typeId: '', // 项目分类
  218. isStart: '', // 是否开工
  219. isStorage: '', // 是否入库
  220. amount: '',
  221. isImportant: '', // 是否省重点
  222. isFocusStart: '', // 是否集中开工
  223. deptIds: '', // 机构id,多选
  224. type: true
  225. },
  226. totalAmount: [
  227. {
  228. name: '5000万以下',
  229. value: '0,4999' // 0 max 1 min
  230. },
  231. {
  232. name: '5000-9999万',
  233. value: '5000,9999'
  234. },
  235. {
  236. name: '1 亿以上',
  237. value: '10000,-'
  238. }
  239. ],
  240. start: [
  241. {
  242. label: '否',
  243. value: 0
  244. },
  245. {
  246. label: '是',
  247. value: 1
  248. }
  249. ],
  250. storage: [
  251. {
  252. label: '否',
  253. value: 0
  254. },
  255. {
  256. label: '是',
  257. value: 1
  258. }
  259. ],
  260. isimport: [
  261. {
  262. label: '否',
  263. value: 0
  264. },
  265. {
  266. label: '是',
  267. value: 1
  268. }
  269. ],
  270. isfocus: [
  271. {
  272. label: '否',
  273. value: 0
  274. },
  275. {
  276. label: '是',
  277. value: 1
  278. }
  279. ],
  280. typeList: [],
  281. showOrg: false,
  282. keyWords: '',
  283. checked: false,
  284. time1: null, // 计划 实际开工时间
  285. time2: null, // 计划 实际入库时间
  286. deptName: '机构选择'
  287. }
  288. },
  289. created() {
  290. this.getTypeList()
  291. },
  292. methods: {
  293. getTypeList() {
  294. this.$api.project.typeList().then(res => {
  295. this.typeList = res.data.records
  296. })
  297. },
  298. sure() {
  299. this.form.type = true
  300. if (this.time1 !== null && this.form.isStart.length === 0) {
  301. this.$message.error('请先选择是否开工')
  302. return
  303. } else if (this.time2 !== null && this.form.isStorage.length === 0) {
  304. this.$message.error('请先选择是否入库')
  305. return
  306. }
  307. if (this.form.isStart === 0) {
  308. this.form.planCommencementTime = this.time1 === null ? '' : this.time1.join(',')
  309. this.form.startTime = ''
  310. } else if (this.form.isStart === 1 && this.time1 !== null) {
  311. this.form.planCommencementTime = ''
  312. this.form.startTime = this.time1.join(',')
  313. } else {
  314. this.form.planCommencementTime = ''
  315. this.form.startTime = ''
  316. }
  317. if (this.form.isStorage === 0) {
  318. this.form.planStorageTime = this.time2 === null ? '' : this.time2.join(',')
  319. this.form.storageTime = ''
  320. } else if (this.form.isStorage === 1 && this.time2 !== null) {
  321. this.form.planStorageTime = ''
  322. this.form.storageTime = this.time2.join(',')
  323. } else {
  324. this.form.planStorageTime = ''
  325. this.form.storageTime = ''
  326. }
  327. this.$bus.emit('serach', this.form)
  328. },
  329. visibleTime(event, type) {
  330. if (event) {
  331. console.log(this.form.isStart)
  332. if (type === 1) {
  333. if (this.form.isStart.length === 0) {
  334. this.$message.error('请先选择是否开工')
  335. return
  336. }
  337. }
  338. if (type === 2) {
  339. if (this.form.isStorage.length === 0) {
  340. this.$message.error('请先选择是否入库')
  341. }
  342. }
  343. }
  344. },
  345. clear() {
  346. this.form.projectName = ''
  347. this.form.typeId = ''
  348. this.form.isStorage = ''
  349. this.form.isStart = ''
  350. this.form.amount = ''
  351. this.form.isFocusStart = ''
  352. this.form.isImportant = ''
  353. this.form.deptIds = ''
  354. this.form.type = false
  355. this.form.planCommencementTime = ''
  356. this.form.startTime = ''
  357. this.form.planStorageTime = ''
  358. this.form.storageTime = ''
  359. this.time1 = null
  360. this.time2 = null
  361. this.deptName = '机构选择'
  362. this.$bus.emit('serach', this.form)
  363. },
  364. changeAmount() {
  365. const tmps = this.form.amount.split(',')
  366. this.form.totalAmountMin = tmps[0] === '-' ? '' : tmps[0]
  367. this.form.totalAmountMax = tmps[1] === '-' ? '' : tmps[1]
  368. },
  369. getOrg() {
  370. if (this.deptList.length > 0) {
  371. this.showOrg = true
  372. return
  373. }
  374. const parentId = [0, 2].includes(this.user.info.viewStage) ? this.user.info.parentDeptId : this.user.info.deptId
  375. this.$api.system.getDeptLazy({parentId}).then(res => {
  376. if (res.code === 200) {
  377. this.showOrg = true
  378. this.deptList = res.data.map(e => {
  379. e.checked = false
  380. return e
  381. })
  382. } else {
  383. this.$message.error(res.msg)
  384. }
  385. })
  386. },
  387. changeChecked(index) {
  388. this.deptList[index].checked = !this.deptList[index].checked
  389. },
  390. orgCheck() {
  391. const checked = this.deptList.filter(sub => sub.checked)
  392. this.form.deptIds = checked.map(sub => sub.id).join(',')
  393. let tmp = checked.map(e => e.deptName)
  394. if (tmp.length > 0) {
  395. this.deptName = tmp[0]
  396. }
  397. this.showOrg = false
  398. },
  399. change() {
  400. if (this.keyWords.length === 0) {
  401. this.deptList.forEach(sub => sub.search = false)
  402. return
  403. }
  404. const tmp = this.deptList.filter(sub => sub.deptName.indexOf(this.keyWords) > -1).map(sub => sub.id)
  405. tmp.forEach(sub => {
  406. const index = this.deptList.findIndex(ele => ele.id === sub)
  407. this.deptList[index].search = true
  408. })
  409. }
  410. }
  411. }
  412. </script>
  413. <style lang="scss" scoped>
  414. .lab {
  415. :deep(.el-form-item__label) {
  416. color: #707070;
  417. font-size: 15px;
  418. font-weight: 500;
  419. }
  420. }
  421. .chose-box {
  422. width: 100%;
  423. border: 1px solid #DDDFE6;
  424. border-radius: 5px;
  425. }
  426. .grid {
  427. display: grid;
  428. grid-template-columns: auto auto auto auto;
  429. }
  430. .org {
  431. border-radius: 8px;
  432. width: 150px;
  433. margin: 10px;
  434. }
  435. .dot {
  436. width: 10px;
  437. height: 10px;
  438. border-radius: 10px;
  439. border: 4px solid #eeeeee;
  440. }
  441. .dot-checked {
  442. width: 10px;
  443. height: 10px;
  444. border-radius: 10px;
  445. border: 4px solid #ECAB56;
  446. .title {
  447. color: white;
  448. }
  449. }
  450. .org-search {
  451. border-radius: 8px;
  452. background: #4E637F;
  453. width: 150px;
  454. margin: 10px;
  455. }
  456. .org-s {
  457. border-radius: 8px;
  458. background: #4E637F;
  459. width: 150px;
  460. margin: 10px;
  461. }
  462. </style>