leadership.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <template>
  2. <view class="leadership">
  3. <nav>
  4. <view class="pull-down" @click="animation2 = !animation2">
  5. 领导干部<span>{{organization}}</span><uni-icons type="bottom" size="25" color="#fff"></uni-icons>
  6. </view>
  7. <view class="operation">
  8. <view class="search" @click="animation = true,animation1 = false">
  9. <image src="../../static/images/sousuo.png" mode="" class="img"></image>
  10. </view>
  11. <view class="arrange" @click="switchover">
  12. <image src="../../static/images/suolue.png" v-show="arrange" mode="" class="img"></image>
  13. <image src="../../static/images/liebiao.png" v-show="!arrange" mode="" class="img"></image>
  14. </view>
  15. </view>
  16. <view class="searchInp" :class="{kai: animation,guan : animation1}">
  17. <image src="../../static/images/fanhui.png" class="img" mode=""
  18. @click="animation = false,animation1 = true"></image>
  19. <u-search :clearabled="true" :showAction="false" shape="square" bgColor="#fff" v-model="value"
  20. @input="associate" @search="searchData"></u-search>
  21. <!-- <u-input @blur="blur" confirm-type="search" @input="associate" v-model="value" type="text" /> -->
  22. </view>
  23. <view class="lianxiang" v-if="lianxiangShow">
  24. <view class="li" v-for="(v,i) in lianxiangData" :key="i" @click="lianxiangSearch(v)">
  25. <span>{{v.a}}</span> <span>{{v.b}}</span>
  26. </view>
  27. </view>
  28. </nav>
  29. <main>
  30. <view v-show="animation2" class="treeMod" @click="animation2 = !animation2">
  31. <view class="treeBox" :class="{kai: animation2,guan : !animation2}">
  32. <ly-tree :tree-data="treeData" node-key="id" @node-click="handleNodeClick">
  33. </ly-tree>
  34. </view>
  35. </view>
  36. <scroll-view v-if="tableData.length != 0" :scroll-top="scrollTop" scroll-y="true" class="scroll-Y"
  37. @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
  38. <view class="calBox" v-show="arrange">
  39. <view class="scroll-view-item" v-for="(v,i) in tableData" :key="i" @click="details(v)">
  40. <view class="content">
  41. <p style="margin-bottom: 10rpx;"><span class="name">{{v.S_Name}}</span><span
  42. class="age">{{v.S_Sex}}</span><span class="dizhi">({{v.S_Birthplace}})</span>
  43. </p>
  44. <p>{{v.S_BirthDate}} 出生 ({{getAge(v.S_BirthDate)}}岁)</p>
  45. <p>{{v.S_JoinPartyTime}} {{v.Party}}</p>
  46. <p>{{v.S_WorkDate}} 参加工作</p>
  47. <p>{{v.S_MaxEdu}}{{v.S_MaxDeg? '、':''}}{{v.S_MaxDeg}}</p>
  48. <p class="zhiwu">现任职务: {{v.S_FullPost}}</p>
  49. </view>
  50. <view class="touxiang">
  51. <image class="img" :src="v.txSrc" mode="aspectFit"></image>
  52. </image>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="tableBox" v-show="!arrange">
  57. <table normal="normal">
  58. <thead>
  59. <tr>
  60. <td>姓名</td>
  61. <td>现任职务</td>
  62. <td>性别</td>
  63. <td>民族</td>
  64. <td>出生年月</td>
  65. <td>籍贯</td>
  66. <td>参加工作时间</td>
  67. <td>入党时间</td>
  68. <td>学历学位</td>
  69. <td>职称</td>
  70. <td>任现职时间</td>
  71. <td>任现职级时间</td>
  72. <td>备注</td>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <tr v-for="(v,i) in tableData" :key="i" @click="details(v)">
  77. <td>{{v.S_Name}}</td>
  78. <td class="twoTd">
  79. {{v.S_FullPost}}
  80. </td>
  81. <td>{{v.S_Sex}}</td>
  82. <td>{{v.S_Nation}}</td>
  83. <td>{{v.S_BirthDate}}</td>
  84. <td>{{v.S_NativePlace}}</td>
  85. <td>{{v.S_WorkDate}}</td>
  86. <td>{{v.S_JoinPartyTime}}</td>
  87. <td>
  88. <p>{{v.S_MaxEdu}}</p>
  89. <p>{{v.S_MaxDeg}}</p>
  90. </td>
  91. <td>{{v.S_Profession}}</td>
  92. <td>{{v.S_MaxAppointDate}}</td>
  93. <td>{{v.S_MaxAppointLevelDate}}</td>
  94. <td></td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </view>
  99. <u-loadmore :status="status" />
  100. </scroll-view>
  101. <view class="noData" v-else>
  102. <image src="../../static/imgs/background.png" class="img" mode=""></image>
  103. </view>
  104. </main>
  105. </view>
  106. </template>
  107. <script>
  108. import LyTree from '@/components/ly-tree/ly-tree.vue'
  109. import sqlLite from '../../utils/sqllite-utils.js';
  110. export default {
  111. components: {
  112. LyTree
  113. },
  114. data() {
  115. return {
  116. // 排列
  117. arrange: true,
  118. // 搜索
  119. value: '',
  120. // 搜索开
  121. animation: false,
  122. // 搜索关
  123. animation1: false,
  124. animation2: false,
  125. // 机构
  126. organization: '',
  127. ready: false, // 这里用于自主控制loading加载状态,避免异步正在加载数据的空档显示“暂无数据”
  128. treeData: [],
  129. // 树配置
  130. defaultProps: {
  131. children: 'children',
  132. label: 'label'
  133. },
  134. // 滚动视图配置
  135. scrollTop: 0,
  136. old: {
  137. scrollTop: 0
  138. },
  139. // 上拉加载更多
  140. status: 'loadmore',
  141. resData: [],
  142. allData: [],
  143. tableData: [],
  144. total: 0,
  145. page: 1,
  146. size: 0,
  147. time: null,
  148. treeAllData: [],
  149. treeArrData: [],
  150. // 树查询数据
  151. treeSearchData: [],
  152. // 搜索联想显示
  153. lianxiangShow: false,
  154. // 联想数据
  155. lianxiangData: []
  156. };
  157. },
  158. created() {
  159. this.getData()
  160. this.getTree()
  161. },
  162. mounted() {},
  163. methods: {
  164. // 处理树结构
  165. setTree(data) {
  166. data.map(v => {
  167. v.children = []
  168. v.label = v.O_ShortName
  169. // v.rganizeId = v.OrganizeId
  170. if (!v.O_Code) {
  171. v.id = '0'
  172. v.pid = null
  173. } else if (v.O_Code.length == 8 || v.O_Code.length == 3) {
  174. v.id = v.O_Code
  175. v.pid = '0'
  176. } else if (v.O_Code.length == 16) {
  177. v.id = v.O_Code
  178. v.pid = "0"
  179. // data[v.pid].children.push(v)
  180. } else if (v.O_Code.length == 24) {
  181. v.id = v.O_Code
  182. v.pid = v.O_Code.slice(0, 16)
  183. } else if (v.O_Code.length == 32) {
  184. v.id = v.O_Code
  185. v.pid = v.O_Code.slice(0, 24)
  186. } else if (v.O_Code.length == 40) {
  187. v.id = v.O_Code
  188. v.pid = v.O_Code.slice(0, 32)
  189. }
  190. })
  191. return data
  192. },
  193. arrayToTreeRec(nodes, pid = null) {
  194. return nodes
  195. .filter((node) => node.pid === pid)
  196. .map((node) => ({
  197. ...node,
  198. children: this.arrayToTreeRec(nodes, node.id)
  199. }));
  200. },
  201. // 切换排列方式
  202. switchover() {
  203. this.arrange = !this.arrange
  204. },
  205. // 年龄
  206. getAge(val) {
  207. if (val) {
  208. let currentYear = new Date().getFullYear() //当前的年份
  209. let calculationYear = new Date(val).getFullYear() //计算的年份
  210. const wholeTime = currentYear + val.substring(4) //周岁时间
  211. const calculationAge = currentYear - calculationYear //按照年份计算的年龄
  212. //判断是否过了生日
  213. if (new Date().getTime() > new Date(wholeTime).getTime()) {
  214. return calculationAge
  215. } else {
  216. return calculationAge - 1
  217. }
  218. } else {
  219. return ''
  220. }
  221. },
  222. // 机构树
  223. handleNodeClick(obj) {
  224. this.treeSearchData = []
  225. this.organization = obj.label
  226. if (obj.data.OrganizeId == 0) {
  227. this.getData()
  228. } else {
  229. sqlLite.selectFromTable(
  230. `select min(PostID),* from Biz_Staff c, Biz_Organize b, Biz_Post a where a.OrganizeId = b.OrganizeId and a.StaffId = c.StaffId and b.O_Code like '${obj.data.O_Code}%' GROUP BY a.StaffId ORDER BY b.O_Order asc,b.O_ParentOrganizeId asc,a.P_staffOrder asc`
  231. ).then((date) => {
  232. this.resData = date
  233. this.allData = this.resData
  234. this.pageData()
  235. })
  236. .catch((e) => {
  237. uni.showToast({
  238. title: '查询失败',
  239. icon: 'none'
  240. })
  241. })
  242. }
  243. },
  244. // 顶部刷新
  245. upper: function(e) {
  246. // this.getData()
  247. },
  248. // 触底事件
  249. lower: function(e) {
  250. this.status = 'loading'
  251. this.pageData()
  252. },
  253. // 滚动事件
  254. scroll: function(e) {
  255. this.old.scrollTop = e.detail.scrollTop
  256. },
  257. // 获取列表数据
  258. getData() {
  259. sqlLite.selectFromTable(
  260. 'select min(PostID),* from Biz_Staff c, Biz_Organize b, Biz_Post a where a.OrganizeId = b.OrganizeId and a.StaffId = c.StaffId GROUP BY a.StaffId ORDER BY b.O_Order asc,b.O_ParentOrganizeId asc,a.P_staffOrder asc'
  261. ).then((date) => {
  262. this.resData = date
  263. this.allData = this.resData
  264. this.pageData()
  265. })
  266. .catch((e) => {
  267. uni.showToast({
  268. title: '查询失败',
  269. icon: 'none'
  270. })
  271. })
  272. },
  273. // 分页
  274. pageData() {
  275. this.size = this.size + 12
  276. this.tableData = this.allData.slice(0, this.size);
  277. this.tableData.map(v => {
  278. if (v.S_Photo) {
  279. v.txSrc = 'file:///storage/emulated/0/QingTianGB_X/Photo/' + v.S_Photo
  280. } else {
  281. if (v.S_Sex == '男') {
  282. v.txSrc = '../../static/imgs/group3.png'
  283. } else {
  284. v.txSrc = '../../static/imgs/group4.png'
  285. }
  286. }
  287. if (v.S_JoinPartyTime.includes(".")) {
  288. v.Party = '中共党员'
  289. } else {
  290. v.Party = v.S_JoinPartyTime
  291. }
  292. })
  293. if (this.tableData.length == this.allData.length) {
  294. this.status = 'nomore'
  295. }
  296. this.total = this.allData.length
  297. },
  298. // 获取机构树
  299. getTree() {
  300. sqlLite.selectFromTable(
  301. 'select O_Code,O_ShortName from Biz_Organize ORDER BY O_Order'
  302. ).then((res) => {
  303. this.treeAllData = res
  304. this.treeArrData = this.setTree(this.treeAllData)
  305. this.treeData = this.arrayToTreeRec(this.treeArrData, null)
  306. // this.treeData[0].children.reverse()
  307. })
  308. .catch((err) => {
  309. uni.showToast({
  310. title: '查询失败',
  311. icon: 'none'
  312. })
  313. })
  314. },
  315. // 搜索联想
  316. associate() {
  317. this.lianxiangData = []
  318. if (this.value) {
  319. let pattern = new RegExp("[\u4E00-\u9FA5]+");
  320. if (pattern.test(this.value)) {
  321. sqlLite.selectFromTable(
  322. `select * from Biz_Staff a, Biz_Party b where a.StaffId = b.StaffId and a.S_Name like "${this.value}%"`
  323. ).then((date) => {
  324. date.forEach(v => {
  325. this.lianxiangData.push({
  326. a: v.S_Name,
  327. b: v.S_NameSpell
  328. })
  329. })
  330. // this.searchData()
  331. })
  332. .catch((e) => {
  333. uni.showToast({
  334. title: '查询失败',
  335. icon: 'none'
  336. })
  337. })
  338. } else {
  339. sqlLite.selectFromTable(
  340. `select * from Biz_Staff a, Biz_Party b where a.StaffId = b.StaffId and a.S_NameSpell like "${this.value}%"`
  341. ).then((date) => {
  342. date.forEach(v => {
  343. this.lianxiangData.push({
  344. a: v.S_NameSpell,
  345. b: v.S_Name,
  346. })
  347. })
  348. })
  349. .catch((e) => {
  350. uni.showToast({
  351. title: '查询失败',
  352. icon: 'none'
  353. })
  354. })
  355. }
  356. this.lianxiangShow = true
  357. } else {
  358. this.lianxiangShow = false
  359. }
  360. },
  361. lianxiangSearch(data) {
  362. let pattern = new RegExp("[\u4E00-\u9FA5]+");
  363. if (pattern.test(data.a)) {
  364. this.value = data.a
  365. } else {
  366. this.value = data.b
  367. }
  368. this.searchData()
  369. },
  370. // 搜索
  371. searchData() {
  372. if (this.value) {
  373. let pattern = new RegExp("[\u4E00-\u9FA5]+");
  374. this.allData = []
  375. this.size = 0
  376. if (pattern.test(this.value)) {
  377. sqlLite.selectFromTable(
  378. `select min(PostID),* from Biz_Staff c, Biz_Organize b, Biz_Post a where a.OrganizeId = b.OrganizeId and a.StaffId = c.StaffId and c.S_Name like "%${this.value}%" GROUP BY a.StaffId ORDER BY b.O_Order asc,b.O_ParentOrganizeId asc,a.P_staffOrder asc`
  379. ).then((date) => {
  380. this.allData = date
  381. this.pageData()
  382. this.lianxiangShow = false
  383. })
  384. .catch((e) => {
  385. uni.showToast({
  386. title: '查询失败',
  387. icon: 'none'
  388. })
  389. })
  390. } else {
  391. sqlLite.selectFromTable(
  392. `select min(PostID),* from Biz_Staff c, Biz_Organize b, Biz_Post a where a.OrganizeId = b.OrganizeId and a.StaffId = c.StaffId and c.S_NameSpell like "%${this.value}%" GROUP BY a.StaffId ORDER BY b.O_Order asc,b.O_ParentOrganizeId asc,a.P_staffOrder asc`
  393. ).then((date) => {
  394. this.allData = date
  395. this.pageData()
  396. this.lianxiangShow = false
  397. })
  398. .catch((e) => {
  399. uni.showToast({
  400. title: '查询失败',
  401. icon: 'none'
  402. })
  403. })
  404. }
  405. this.animation1 = true
  406. // this.resData.map(item => {
  407. // if (item.S_FullPost.indexOf(text) !== -1 || item.S_Name.indexOf(text) !== -1 || item
  408. // .S_MaxEduKey
  409. // .indexOf(text) !== -1) {
  410. // this.allData.push(item);
  411. // }
  412. // });
  413. this.pageData()
  414. } else {
  415. this.allData = []
  416. this.size = 0
  417. this.allData = this.resData
  418. this.animation1 = true
  419. this.pageData()
  420. }
  421. },
  422. // 树查询
  423. treeSearch(text) {
  424. this.allData = []
  425. this.size = 0
  426. this.resData.map(item => {
  427. text.forEach(v => {
  428. if (item.S_StatisticsOrganize == v) {
  429. this.allData.push(item);
  430. }
  431. })
  432. });
  433. this.pageData()
  434. },
  435. // 详情
  436. details(data) {
  437. uni.setStorage({
  438. key: 'det',
  439. data: data
  440. })
  441. uni.navigateTo({
  442. url: '/pages/leadership/userDetails',
  443. animationType: 'pop-in',
  444. animationDuration: 300
  445. })
  446. },
  447. },
  448. }
  449. </script>
  450. <style lang="scss" scoped>
  451. .leadership {
  452. width: 100%;
  453. height: 100%;
  454. background-color: #fafafa;
  455. font-size: 24rpx;
  456. nav {
  457. width: 100%;
  458. height: 10%;
  459. background-color: #6dbeeb;
  460. color: #fff;
  461. padding: 0 40rpx;
  462. display: flex;
  463. justify-content: space-between;
  464. align-items: center;
  465. position: relative;
  466. .pull-down {
  467. display: flex;
  468. align-items: center;
  469. font-size: 36rpx;
  470. span {
  471. margin: 0 20rpx;
  472. }
  473. }
  474. .operation {
  475. display: flex;
  476. .search {
  477. margin-right: 50rpx;
  478. }
  479. .img {
  480. width: 50rpx;
  481. height: 50rpx;
  482. }
  483. }
  484. @keyframes myfirst {
  485. 0% {
  486. width: 0rpx;
  487. }
  488. 100% {
  489. width: 100%;
  490. }
  491. }
  492. @keyframes myfirst1 {
  493. 0% {
  494. width: 100%;
  495. }
  496. 100% {
  497. width: 0rpx;
  498. }
  499. }
  500. .kai {
  501. animation: myfirst 0.5s;
  502. animation-fill-mode: forwards;
  503. }
  504. .guan {
  505. animation: myfirst1 0.3s;
  506. animation-fill-mode: forwards;
  507. }
  508. .searchInp {
  509. width: 0;
  510. height: 70%;
  511. background-color: #fff;
  512. position: absolute;
  513. top: 50%;
  514. right: 0;
  515. transform: translateY(-50%);
  516. display: flex;
  517. align-items: center;
  518. overflow: hidden;
  519. .img {
  520. width: 50rpx;
  521. height: 50rpx;
  522. margin: 0 30rpx;
  523. }
  524. }
  525. .lianxiang {
  526. position: absolute;
  527. z-index: 200;
  528. top: 90%;
  529. left: 0;
  530. width: 100%;
  531. max-height: 800rpx;
  532. overflow-y: scroll;
  533. background-color: #fff;
  534. .li {
  535. padding-left: 130rpx;
  536. height: 70rpx;
  537. line-height: 70rpx;
  538. color: #333;
  539. border-bottom: 1px solid #dcdcdc;
  540. span {
  541. margin-right: 20rpx;
  542. font-size: 30rpx;
  543. }
  544. }
  545. }
  546. }
  547. main {
  548. width: 100%;
  549. height: 90%;
  550. position: relative;
  551. @keyframes myfirst2 {
  552. 0% {
  553. width: 0;
  554. }
  555. 100% {
  556. width: 30%;
  557. }
  558. }
  559. @keyframes myfirst3 {
  560. 0% {
  561. width: 30%;
  562. }
  563. 100% {
  564. width: 0;
  565. }
  566. }
  567. .kai {
  568. animation: myfirst2 0.4s;
  569. animation-fill-mode: forwards;
  570. }
  571. .guan {
  572. animation: myfirst3 0.2s;
  573. animation-fill-mode: forwards;
  574. overflow: hidden;
  575. }
  576. .treeMod {
  577. width: 100%;
  578. height: 100%;
  579. position: absolute;
  580. z-index: 1;
  581. }
  582. .treeBox {
  583. width: 0;
  584. height: 100%;
  585. position: absolute;
  586. top: 0;
  587. left: 0;
  588. z-index: 1;
  589. overflow: scroll;
  590. }
  591. .scroll-Y {
  592. height: 100%;
  593. padding-bottom: 20rpx;
  594. .calBox {
  595. width: 100%;
  596. display: flex;
  597. padding: 0 20rpx;
  598. flex-wrap: wrap;
  599. // justify-content: space-between;
  600. .scroll-view-item {
  601. overflow: hidden;
  602. width: 32%;
  603. // height: 28vh;
  604. background-color: #fff;
  605. margin-top: 30rpx;
  606. border-radius: 6rpx;
  607. box-shadow: 1px 1px 3px 1px #ccc;
  608. padding: 30rpx;
  609. display: flex;
  610. margin-right: 32rpx;
  611. &:nth-child(3n) {
  612. margin-right: 0;
  613. }
  614. .content {
  615. flex: 1;
  616. line-height: 44rpx;
  617. letter-spacing: 0rpx;
  618. p {
  619. color: #737373;
  620. font-size: 36rpx;
  621. .name {
  622. font-size: 46rpx;
  623. color: #41a7d4;
  624. font-weight: 600;
  625. }
  626. .age {
  627. color: #333;
  628. margin-left: 30rpx;
  629. margin-right: 15rpx;
  630. font-weight: 600;
  631. font-size: 40rpx;
  632. }
  633. .dizhi {
  634. color: #333;
  635. font-weight: 600;
  636. }
  637. }
  638. .zhiwu {
  639. overflow: hidden;
  640. text-overflow: ellipsis;
  641. -webkit-line-clamp: 2;
  642. display: -webkit-box;
  643. -webkit-box-orient: vertical;
  644. }
  645. }
  646. .touxiang {
  647. width: 35%;
  648. max-width: 200rpx;
  649. height: 80%;
  650. max-height: 280rpx;
  651. background-color: #e6e6e7;
  652. // border: 1px solid #dededf;
  653. .img {
  654. width: 100%;
  655. height: 100%;
  656. }
  657. }
  658. }
  659. }
  660. .tableBox {
  661. width: 100%;
  662. padding: 0 10rpx;
  663. table {
  664. width: 100%;
  665. border-collapse: collapse;
  666. text-align: center;
  667. // white-space: nowrap;
  668. thead {
  669. position: sticky;
  670. top: 0;
  671. background-color: white;
  672. tr {
  673. border: 1px solid #999;
  674. td {
  675. border: 1px solid #999;
  676. }
  677. }
  678. }
  679. tbody {
  680. tr {
  681. .twoTd {
  682. max-width: 300rpx;
  683. width: 300rpx;
  684. word-wrap: break-word;
  685. word-break: break-all;
  686. }
  687. }
  688. }
  689. th,
  690. td {
  691. border: 1px solid #999;
  692. text-align: center;
  693. padding: 20px 0;
  694. word-wrap: break-word;
  695. word-break: break-all;
  696. }
  697. }
  698. }
  699. }
  700. .noData {
  701. width: 100%;
  702. height: 100%;
  703. .img {
  704. width: 100%;
  705. height: 100%;
  706. }
  707. }
  708. }
  709. }
  710. </style>