index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="uni-container uni-container-bg">
  3. <view class="container" :style="'height: ' + (screenHeight - 75) + 'px'">
  4. <!-- 搜索框 -->
  5. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  6. <uni-col :span="24">
  7. <view class="u-page__tag-item">
  8. <u-search placeholder="请输入单位人员名称" bgColor="#edf6f9" borderColor="#4cb2b6" v-model="keyword"
  9. :showAction="true" @custom="search(keyword)"></u-search>
  10. </view>
  11. </uni-col>
  12. </uni-row>
  13. <!-- 下拉框 -->
  14. <view class="u-page__tag-item"
  15. style="margin-bottom: 26upx;width: 700upx;border-bottom: 2px solid #55cbbf;background-color: #f5f7fa;">
  16. <u-form>
  17. <u-form-item prop="orgName" @click="
  18. showOrg = true;
  19. hideKeyboard();
  20. " label="单位选择:" labelWidth="80px">
  21. <u--input border="none" disabled v-model="formData.orgName" placeholder="请选择所属单位"></u--input>
  22. <u-icon slot="right" name="arrow-down"></u-icon>
  23. </u-form-item>
  24. </u-form>
  25. </view>
  26. <!-- v-for="(item, index) in tableData" -->
  27. <view v-if="tableData.length>0 && isLoaded">
  28. <!-- 宫格 -->
  29. <uni-card v-for="(item, index) in tableData" :key="index"
  30. @click.native="onClick(item, formData.orgName)">
  31. <!-- <u-icon
  32. v-if="item.avatar == '' || item.avatar == null || item.avatar == undefined"
  33. customStyle="margin-top:20px; border-radius: 50%;"
  34. :name="avatar"
  35. :size="70"
  36. ></u-icon>
  37. <u-icon v-else customStyle="margin-top:20px; border-radius: 50%;" :name="item.avatar" :size="70"></u-icon> -->
  38. <!-- 姓名 -->
  39. <view class="grid-text"><text class="name-align-task">姓名:</text>{{ item.empRyxm }}</view>
  40. <!-- 岗位 -->
  41. <view v-if="item.empGw == '' || item.empGw == null || item.empGw == undefined" class="grid-text">无
  42. </view>
  43. <view v-else class="grid-text"><text class="name-align-task">岗位:</text>{{ item.empGw }}</view>
  44. <view class="grid-text"><text class="name-align-task">联系电话:</text>{{ item.linkTel }}</view>
  45. <view class="grid-text"><text class="name-align-task">职业资格证书:</text>{{ item.empGw }}</view>
  46. </uni-card>
  47. </uni-card>
  48. </view>
  49. <!-- tableData为空时显示 -->
  50. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  51. <view class="text-gray" style="padding-top: 20px;">
  52. <img :src="tan90" alt="暂无数据" />
  53. </view>
  54. <!-- tableData为空时显示 -->
  55. <view>
  56. <image :src="Group" @click="addClick" class="tiantupian"></image>
  57. </view>
  58. <u-action-sheet :show="showOrg" :actions="actions" title="请选择单位" @close="showOrg = false"
  59. @select="sexSelect">
  60. </u-action-sheet>
  61. <!-- 加载中 -->
  62. <isLodingModel></isLodingModel>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. var that = '';
  69. import {
  70. getStaff, //获取人员信息列表
  71. delStaff, //删除人员信息
  72. getOrgId
  73. } from '@/api/staff_info';
  74. import config from '@/config'
  75. const baseUrlImg = config.baseUrlImg
  76. export default {
  77. data() {
  78. return {
  79. isLoaded: false,
  80. // avatar: `${baseUrlImg}/avatar.jpg`,
  81. showOrg: false,
  82. actions: [],
  83. searchVal: '',
  84. Group: `${baseUrlImg}/checkActive/Group.png`,
  85. orgId: '',
  86. // 数据
  87. tableData: {
  88. // avatar:''
  89. },
  90. title: '是否删除该数据项?',
  91. content: '确认删除?',
  92. id: '',
  93. tan90: `${baseUrlImg}/tan90.png`,
  94. // 每页数据量
  95. pageSize: 5,
  96. // 当前页
  97. pageNo: 1,
  98. // 数据总量
  99. total: 0,
  100. // tableData数据加载中
  101. loading: false,
  102. // 初始化时搜索框的值
  103. keyword: '',
  104. // 开始时间与结束时间
  105. formData: {},
  106. show: false,
  107. screenHeight: this.$screenHeight,
  108. wheight: ''
  109. };
  110. },
  111. // 在 vue页面,向起始页通过事件传递数据
  112. onLoad: function(option) {
  113. getOrgId({
  114. pageNo: this.pageNo,
  115. pageSize: this.pageSize,
  116. userId: this.$store.state.user.id
  117. }).then(response => {
  118. // 取到用户对应的单位名称与id
  119. response.data.map(v => {
  120. this.actions.push({
  121. id: v.dwid,
  122. name: v.orgName
  123. });
  124. });
  125. if (response.data.length > 0) {
  126. console.log(response.data, '21321312');
  127. this.formData.orgName = response.data[0].orgName;
  128. this.formData.orgId = response.data[0].dwid;
  129. }
  130. });
  131. },
  132. watch: {
  133. loading: {
  134. handler(newLength, oldLength) {
  135. this.$modal.isLoadingModel(this.loading)
  136. },
  137. immediate: true
  138. }
  139. },
  140. onShow() {
  141. this.actions = []
  142. this.tableData = []
  143. this.getData();
  144. },
  145. mixins: [uni.$u.mixin],
  146. methods: {
  147. search(val) {
  148. console.log(val, 'valvals');
  149. this.isLoaded = false
  150. this.loading = true
  151. this.tableData = []
  152. this.getData(1)
  153. },
  154. // 模态框内容
  155. showModal(val) {
  156. this.show = true;
  157. this.id = val.id;
  158. },
  159. confirm() {
  160. this.show = false;
  161. delStaff({
  162. id: this.id
  163. }).then(response => {
  164. this.isLoaded = false
  165. this.tableData = []
  166. this.getData();
  167. // this.tableData = response.data;
  168. console.log(this.tableData, '删除');
  169. });
  170. },
  171. close() {
  172. this.show = false;
  173. console.log('close');
  174. },
  175. cancel() {
  176. this.show = false;
  177. console.log('cancel');
  178. },
  179. // 分页触发
  180. change(e) {
  181. console.log(e.current);
  182. this.$refs.table.clearSelection();
  183. this.getData(e.current);
  184. },
  185. sexSelect(e) {
  186. this.formData.orgId = e.id;
  187. this.formData.orgName = e.name;
  188. console.log(e, 'eeee');
  189. // 获取培训演练信息详细信息
  190. getStaff({
  191. pageNo: this.pageNo,
  192. pageSize: this.pageSize,
  193. sjjg: this.formData.orgId,
  194. }).then(response => {
  195. this.tableData = response.data;
  196. });
  197. },
  198. //查看详情
  199. addClickDetail(val) {
  200. this.isLoaded = false
  201. uni.navigateBack({
  202. delta: 1
  203. });
  204. },
  205. // 获取数据
  206. getData(pageNo, value = '') {
  207. that = this;
  208. this.loading = true;
  209. // 获取人员信息详细信息
  210. getStaff({
  211. pageNo: this.pageNo,
  212. pageSize: this.pageSize,
  213. sjjg: this.formData.orgId,
  214. empRyxm: this.keyword
  215. }).then(response => {
  216. this.isLoaded = true
  217. this.tableData = [...this.tableData, ...response.data]
  218. this.loading = false
  219. });
  220. },
  221. // 传递数据
  222. onClick(val, orgName) {
  223. this.isLoaded = false
  224. uni.navigateTo({
  225. url: '/pagesA/fire/staff_info/staff_details/staff_details?id=' + val.id + '&orgName=' +
  226. orgName,
  227. events: {
  228. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  229. acceptDataFromOpenedPage: function(val) {
  230. console.log(val, '打开页面传送到当前页面的数据');
  231. }
  232. },
  233. success: function(res) {
  234. // 通过eventChannel向被打开页面传送数据
  235. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  236. }
  237. });
  238. },
  239. // 删除单位人员信息
  240. onClickDel(val) {
  241. this.id = val.id;
  242. console.log(this.id);
  243. delStaff({
  244. id: this.id
  245. }).then(response => {
  246. this.tableData = []
  247. this.getData();
  248. // this.tableData = response.data;
  249. console.log(this.tableData, '获取人员信息详细信息获取人员信息详细信息获取人员信息详细信息获取人员信息详细信息');
  250. });
  251. },
  252. // 隐藏键盘
  253. hideKeyboard() {
  254. uni.hideKeyboard();
  255. },
  256. // 添加
  257. addClick() {
  258. uni.navigateTo({
  259. url: '/pagesA/fire/staff_info/add_staff/add_staff'
  260. });
  261. },
  262. // 触底的事件
  263. onReachBottom() {
  264. // 判断是否还有下一页数据
  265. if (this.pageNo * this.pageSize >= this.total)
  266. return uni.showToast({
  267. title: `数据加载完毕`
  268. });
  269. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  270. if (this.loading) return;
  271. this.pageNo += 1;
  272. this.getData(this.pageNo);
  273. }
  274. }
  275. };
  276. </script>
  277. <style lang="scss" scoped>
  278. body {
  279. background-color: #f5f7f9;
  280. }
  281. page {
  282. background-color: #f5f7f9;
  283. }
  284. /deep/ .u-tabs__wrapper[data-v-0de61367],
  285. .u-tabs__wrapper.data-v-0de61367,
  286. /deep/ .u-tabs__wrapper {
  287. width: 99%;
  288. }
  289. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  290. /deep/.u-tabs__wrapper__nav__item,
  291. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367 {
  292. padding: 0 60rpx;
  293. }
  294. .uni-container {
  295. padding-right: 20upx;
  296. }
  297. .addInsp {
  298. width: 40px;
  299. position: fixed;
  300. right: 4px;
  301. z-index: 99999;
  302. }
  303. ::v-deep .u-icon__icon {
  304. margin-right: 0px !important;
  305. }
  306. .an-niu {
  307. float: left;
  308. font-size: 10px;
  309. text-align: center;
  310. color: #fff;
  311. .detail {
  312. width: 72px;
  313. height: 60rpx;
  314. padding: 8px;
  315. border-radius: 30px;
  316. background-color: #f7c41e;
  317. margin-right: 20rpx;
  318. text-align: center;
  319. line-height: 60rpx;
  320. }
  321. .detailDel {
  322. width: 60px;
  323. height: 60rpx;
  324. border-radius: 30px;
  325. background-color: #ff2e31;
  326. color: white;
  327. margin-right: 20rpx;
  328. text-align: center;
  329. line-height: 60rpx;
  330. }
  331. }
  332. /deep/.segmented-control__item--button {
  333. background-color: rgb(76, 178, 182) !important;
  334. }
  335. /deep/.segmented-control__item--button--active {
  336. background-color: #ffffff !important;
  337. }
  338. /deep/.uni-card {
  339. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  340. border-radius: 30rpx;
  341. }
  342. .tiantupian {
  343. width: 110rpx;
  344. height: 110rpx;
  345. position: fixed;
  346. right: 15px;
  347. bottom: 80rpx;
  348. }
  349. //列表样式
  350. .titles {
  351. font-weight: 600;
  352. margin-bottom: 10rpx;
  353. color: black;
  354. font-size: 32rpx;
  355. }
  356. .grid-text {
  357. font-size: 15px;
  358. color: #434548;
  359. padding: 10rpx 0 5rpx 0rpx;
  360. /* #ifndef APP-PLUS */
  361. box-sizing: border-box;
  362. /* #endif */
  363. }
  364. .conts {
  365. max-width: 470rpx;
  366. display: -webkit-box;
  367. /*弹性伸缩盒子模型显示*/
  368. -webkit-box-orient: vertical;
  369. /*排列方式*/
  370. -webkit-line-clamp: 1;
  371. /*显示文本行数*/
  372. overflow: hidden;
  373. /*溢出隐藏*/
  374. color: #274647;
  375. text-overflow: ellipsis;
  376. /*不知道干嘛的*/
  377. .conts-title {
  378. margin-right: 10rpx;
  379. color: #728f90;
  380. }
  381. }
  382. /deep/ .u-form-item__body__left__content__label {
  383. font-size: 28upx !important;
  384. }
  385. /deep/.u-action-sheet {
  386. overflow-y: auto;
  387. height: 1000rpx;
  388. background-color: #fff;
  389. }
  390. </style>