index.vue 10.0 KB

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