index.vue 9.6 KB

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