index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
  3. <u-navbar :titleStyle="{ color: '#000' }" :autoBack="true" title="项目列表" :placeholder="true" :safeAreaInsetTop="true" bgColor="#fff">
  4. <template #left>
  5. <view class="u-navbar__content__left__item">
  6. <u-icon name="arrow-left" size="20" color="#000"></u-icon>
  7. </view>
  8. </template>
  9. <template #right>
  10. <view class="u-navbar__content__right__item">
  11. <u-icon name="plus" size="20" color="#000" @click="handleSubmit('insert')"></u-icon>
  12. </view>
  13. </template>
  14. </u-navbar>
  15. <u-tabs
  16. :list="tabsList"
  17. :current="tabsCurrent"
  18. @click="tabsClick"
  19. lineColor="#333"
  20. :activeStyle="{ color: '#333', fontSize: '14px' }"
  21. :inactiveStyle="{ color: '#909399', fontSize: '14px' }"
  22. :scrollable="false"
  23. ></u-tabs>
  24. </u-sticky>
  25. <oa-scroll
  26. customClass="list-container scroll-height"
  27. :pageSize="pageSize"
  28. :total="total"
  29. :isSticky="true"
  30. :customStyle="{
  31. //#ifdef APP-PLUS || MP-WEIXIN
  32. height: 'calc(100vh - 132px)',
  33. //#endif
  34. //#ifdef H5
  35. height: 'calc(100vh - 132px)',
  36. //#endif
  37. }"
  38. :refresherLoad="true"
  39. :refresherEnabled="true"
  40. :refresherDefaultStyle="'none'"
  41. :refresherThreshold="44"
  42. :lowerThreshold="44"
  43. :refresherBackground="'#f5f6f7'"
  44. @load="load"
  45. @refresh="refresh"
  46. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  47. >
  48. <template #default>
  49. <view class="projectSearchBox" >
  50. <u-input v-model="projectTypeName" disabledColor="#fff" disabled clearable @click="handleAction('项目类型',project_type)" placeholder="项目类型" suffixIcon="arrow-down" suffixIconStyle="color: #909399" />
  51. <u-input v-model="projectName" placeholder="请输入项目名称" clearable prefixIcon="search" size="small" />
  52. <!-- <u-button type="primary" @click="selectListApi">搜索</u-button> -->
  53. <u-picker
  54. :show="actionShow"
  55. :columns="projectTypeList"
  56. title="请选择项目类型"
  57. keyName="label"
  58. visibleItemCount="6"
  59. :closeOnClickOverlay="true"
  60. @close="actionShow = false"
  61. @cancel="actionShow = false"
  62. @confirm="selectAction"
  63. ></u-picker>
  64. </view>
  65. <view class="menu-list m0">
  66. <view class="list-cell" style="color: #666666; line-height: 25px" v-for="(base, index) in dataList" :key="index">
  67. <view class="content-area-top menu-item">
  68. <view class="content-area-top-name" style="color: #559AFF;" @click="toProjectMange(base.id)">{{ base.projectName }} </view>
  69. <u-icon class="content-area-top-icon" name="more-dot-fill" size="20" color="#000" @click="moreClick(base)"></u-icon>
  70. </view>
  71. <view class="content-area-row_wrap menu-item">
  72. <view class="content-area-row_wrap-view"> 负责人: {{ proxy.$common.mapping("nickName", "userId", base.projectHead, userDate) }} </view>
  73. <view class="content-area-row_wrap-view">
  74. 状态:
  75. <uni-tag :text='proxy.$common.mapping("label", "value", base.projectStatus, project_status)' :type='proxy.$common.mapping("elTagType", "value", base.projectStatus, project_status)' />
  76. </view>
  77. <view class="content-area-row_wrap-view">
  78. 类型:
  79. <uni-tag :text='proxy.$common.mapping("label", "value", base.projectStatus, project_type)' :type='proxy.$common.mapping("elTagType", "value", base.projectStatus, project_type)' />
  80. </view>
  81. <view class="content-area-row_wrap-view" style="display: block">
  82. 成员:<span>{{ proxy.$common.mapping("nickName", "userId", base.projectMember, userDate) }} </span>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. </oa-scroll>
  89. <oa-tabbar :tabbarValue="2" :tabbarList="proxy.$constData.projectTabbar" :isSwitchTab="false"></oa-tabbar>
  90. <u-popup :show="popup.show" mode="bottom" bgColor="#fff" :round="10" @close="popup.show = false">
  91. <view
  92. :style="{
  93. borderTopLeftRadius: '10px',
  94. borderTopRightRadius: '10px',
  95. overflow: 'hidden',
  96. }"
  97. >
  98. <u-button
  99. class="custom-style"
  100. type="info"
  101. size="normal"
  102. text="加入项目"
  103. :customStyle="{
  104. height: '50px',
  105. color: '#3c9cff',
  106. borderWidth: 0,
  107. borderRadius: 0,
  108. borderBottomWidth: '1px',
  109. }"
  110. @click="handleModal('join', `确认加入名为 “ ${eventList.projectName} ” 的项目?`)"
  111. v-if="eventList.projectMember.indexOf(useStore.userId) == -1"
  112. ></u-button>
  113. <u-button
  114. class="custom-style"
  115. type="info"
  116. size="normal"
  117. text="退出项目"
  118. :customStyle="{
  119. height: '50px',
  120. color: '#f9ae3d',
  121. borderWidth: 0,
  122. borderRadius: 0,
  123. borderBottomWidth: '1px',
  124. }"
  125. @click="handleModal('exit', `确认退出名为 “ ${eventList.projectName} ” 的项目?`)"
  126. v-if="eventList.projectMember.indexOf(useStore.userId) != -1"
  127. ></u-button>
  128. <u-button
  129. class="custom-style"
  130. type="info"
  131. size="normal"
  132. text="编辑项目"
  133. :customStyle="{
  134. height: '50px',
  135. color: '#3c9cff',
  136. borderWidth: 0,
  137. borderRadius: 0,
  138. borderBottomWidth: '1px',
  139. }"
  140. @click="handleSubmit('update', eventList)"
  141. v-if="eventList.projectHead == useStore.userId"
  142. ></u-button>
  143. <u-button
  144. class="custom-style"
  145. type="info"
  146. size="normal"
  147. text="删除项目"
  148. :customStyle="{
  149. height: '50px',
  150. color: '#f56c6c',
  151. borderWidth: 0,
  152. borderRadius: 0,
  153. borderBottomWidth: '3px',
  154. }"
  155. @click="handleModal('delete', `确认删除名为 “ ${eventList.projectName} ” 的项目?`)"
  156. v-if="eventList.projectHead == useStore.userId"
  157. ></u-button>
  158. <u-button
  159. class="custom-style"
  160. type="info"
  161. size="normal"
  162. text="取消"
  163. :customStyle="{
  164. height: '50px',
  165. color: '#3c9cff',
  166. border: 'none',
  167. borderRadius: 0,
  168. }"
  169. @click="popup.show = false"
  170. ></u-button>
  171. </view>
  172. </u-popup>
  173. <u-modal
  174. :show="modal.show"
  175. title="操作提醒"
  176. :content="modal.content"
  177. :showCancelButton="true"
  178. :closeOnClickOverlay="true"
  179. @confirm="handleSubmit(state.modal.type, eventList)"
  180. @cancel="modal.show = false"
  181. @close="modal.show = false"
  182. ></u-modal>
  183. </template>
  184. <script setup>
  185. /*----------------------------------依赖引入-----------------------------------*/
  186. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  187. import { ref, reactive, computed, getCurrentInstance, toRefs, inject,watchEffect} from "vue";
  188. /*----------------------------------接口引入-----------------------------------*/
  189. import { projectApi } from "@/api/business/project.js";
  190. import { dUserList } from "@/api/system/user.js";
  191. /*----------------------------------组件引入-----------------------------------*/
  192. /*----------------------------------store引入-----------------------------------*/
  193. import { useStores } from "@/store/modules/index";
  194. /*----------------------------------公共方法引入-----------------------------------*/
  195. /*----------------------------------公共变量-----------------------------------*/
  196. const { proxy } = getCurrentInstance();
  197. const useStore = useStores();
  198. const { project_type,project_status } = proxy.useDict("project_type","project_status");
  199. /*----------------------------------变量声明-----------------------------------*/
  200. const state = reactive({
  201. loading: false,
  202. tabsList: [
  203. { name: "全部", value: "" },
  204. { name: "我负责", value: 1 },
  205. { name: "我参与", value: 2 },
  206. ],
  207. tabsCurrent: 0,
  208. dataList: [],
  209. pageSize: 20,
  210. current: 1,
  211. total: 0,
  212. userDate: [],
  213. popup: {
  214. show: false, //弹窗显示
  215. content: "", //提示信息
  216. },
  217. modal: {
  218. type: "", //操作类型
  219. show: false, //弹窗显示
  220. content: "", //提示信息
  221. },
  222. eventList: {}, //数据存储
  223. projectName:'',
  224. projectTypeName: "", //项目类型名称
  225. actionShow: false,
  226. projectType: "", //项目类型
  227. projectTypeList:[[]],
  228. });
  229. const { tabsList, tabsCurrent, dataList, pageSize, current, total, userDate, popup, modal, eventList,array,index,projectTypeName,actionShow,projectType,projectTypeList,projectName} = toRefs(state);
  230. /**
  231. * @action弹出框点击事件
  232. */
  233. function handleAction(value,event, index, ind) {
  234. if (value == "项目类型") {
  235. state.projectTypeList[0] = event
  236. }
  237. state.actionShow = true;
  238. }
  239. /**
  240. * @action弹出框选择事件
  241. */
  242. function selectAction(e) {
  243. state.projectType = e.value[0].value;
  244. state.projectTypeName = e.value[0].label;
  245. state.actionShow = false;
  246. }
  247. /**
  248. * @页面初始化
  249. */
  250. function init() {
  251. dUserList().then((res) => {
  252. state.userDate = res.data;
  253. });
  254. selectListApi();
  255. }
  256. /**
  257. * 操作弹框提醒
  258. * @param type 操作类型
  259. * @param content 提示内容
  260. */
  261. function handleModal(type, content) {
  262. state.modal.show = true;
  263. state.modal.type = type;
  264. state.modal.content = content;
  265. }
  266. /** 确定按钮点击事件 */
  267. function handleSubmit(type, item) {
  268. if (type === "insert") {
  269. proxy.$tab.navigateTo(`/pages/business/common/projectMange/list/addEdit`);
  270. } else if (type === "update") {
  271. proxy.$tab.navigateTo(`/pages/business/common/projectMange/list/addEdit?id=${item.id}`);
  272. } else if (type === "delete") {
  273. projectApi()
  274. .ProjectsDelete(item.id)
  275. .then(() => {
  276. proxy.$modal.msg("项目删除成功!");
  277. selectListApi();
  278. })
  279. .catch((errors) => {
  280. proxy.$modal.msg(errors);
  281. });
  282. } else if (type === "exit") {
  283. projectApi()
  284. .ProjectsExit(item.id)
  285. .then(() => {
  286. proxy.$modal.msg("项目退出成功!");
  287. selectListApi();
  288. })
  289. .catch((errors) => {
  290. proxy.$modal.msg(errors);
  291. });
  292. } else if (type === "join") {
  293. projectApi()
  294. .ProjectsJoin(item.id)
  295. .then(() => {
  296. proxy.$modal.msg("项目加入成功!");
  297. selectListApi();
  298. })
  299. .catch((errors) => {
  300. proxy.$modal.msg(errors);
  301. });
  302. }
  303. state.modal.show = false;
  304. state.popup.show = false;
  305. }
  306. /** 更多按钮点击事件 */
  307. function moreClick(event) {
  308. state.popup.show = true;
  309. state.eventList = event;
  310. }
  311. /**
  312. * @列表查询
  313. * @api接口查询
  314. */
  315. function selectListApi() {
  316. state.loading = true;
  317. projectApi()
  318. .ProjectsList({
  319. projectAscription: state.tabsList[state.tabsCurrent].value,
  320. pageNum: state.current,
  321. pageSize: state.pageSize,
  322. projectType: state.projectType,
  323. projectName: state.projectName,
  324. })
  325. .then((requset) => {
  326. state.dataList = requset.data.records;
  327. state.total = requset.data.total;
  328. state.loading = false;
  329. })
  330. .catch((err) => {
  331. state.loading = false;
  332. });
  333. }
  334. /**
  335. * @scrollView加载数据
  336. */
  337. function load() {
  338. state.pageSize += 10;
  339. init();
  340. }
  341. /**
  342. * @scrollView刷新数据
  343. */
  344. function refresh() {
  345. state.pageSize = 20;
  346. init();
  347. }
  348. /**
  349. * @tabs点击事件
  350. */
  351. function tabsClick(e) {
  352. state.tabsCurrent = e.index;
  353. state.projectName='';
  354. state.projectType='';
  355. state.projectTypeName=''
  356. init();
  357. }
  358. /**
  359. * 跳转项目概览
  360. * @param id 项目id
  361. */
  362. function toProjectMange(id) {
  363. proxy.$tab.navigateTo(`/pages/business/common/projectMange/overview/index?id=${id}`);
  364. }
  365. onReady(() => {});
  366. onShow(() => {
  367. init();
  368. //调用系统主题颜色
  369. proxy.$settingStore.systemThemeColor([1]);
  370. });
  371. watchEffect(() => {
  372. selectListApi();
  373. });
  374. onLoad((options) => {});
  375. </script>
  376. <style lang="scss" scoped>
  377. :deep(.u-modal__content) {
  378. font-size: 14px;
  379. justify-content: left;
  380. }
  381. </style>
  382. <style lang="scss" scoped>
  383. .projectSearchBox {
  384. margin:20px 4% ;width:92%;vertical-align:middle;
  385. position:relative;
  386. display:flex;
  387. :deep(.u-input--radius, .u-input--square){
  388. border-radius:0
  389. }
  390. .u-input{
  391. display:inline-block;background:#fff;height:34px;line-height:34px;padding:0 5px;
  392. .uni-input-input{
  393. font-size:12px!important;
  394. }
  395. :deep(.u-input__content__prefix-icon){
  396. position:absolute;
  397. right:8px;
  398. .uicon-search{
  399. font-size:16px
  400. }
  401. }
  402. }
  403. .u-input:first-child{
  404. flex:2;
  405. border-top-left-radius: 20px;
  406. border-bottom-left-radius: 20px;
  407. border-right:none;
  408. }
  409. .u-input:nth-child(2){
  410. flex:4;
  411. // width:70%;
  412. border-top-right-radius: 20px;
  413. border-bottom-right-radius: 20px;
  414. // border-left:none
  415. }
  416. .u-popup{
  417. flex:0;
  418. }
  419. .u-button{
  420. width:50px;
  421. position:absolute;
  422. right:0px;
  423. top:0;
  424. height:32px;
  425. line-height:32px;
  426. }
  427. }
  428. .list-container {
  429. .content-area {
  430. &-top {
  431. font-size: 16px;
  432. font-weight: 600;
  433. color: #000000;
  434. width: 100%;
  435. float: right;
  436. &-time {
  437. max-width: 70%;
  438. margin: auto 0;
  439. font-size: 14px;
  440. color: rgb(102, 102, 102);
  441. }
  442. &-name {
  443. font-size: 14px;
  444. max-width: 70%;
  445. text-align: left;
  446. color: #000;
  447. }
  448. &-status {
  449. max-width: 30%;
  450. margin: auto 0 auto auto;
  451. font-size: 12px;
  452. color: #ffffff;
  453. padding: 0 5px;
  454. border-radius: 20px;
  455. line-height: 20px;
  456. }
  457. &-icon {
  458. max-width: 30%;
  459. margin: auto 0 auto auto;
  460. }
  461. }
  462. &-row_wrap {
  463. font-size: 13px;
  464. flex-flow: row wrap;
  465. &-view {
  466. display: flex;
  467. min-width: 100%;
  468. > .iconfont {
  469. font-size: 14px;
  470. color: #909399;
  471. margin-left: 5px;
  472. }
  473. &-status {
  474. margin: auto 0 auto 0;
  475. font-size: 12px;
  476. font-weight: 600;
  477. color: #ffffff;
  478. padding: 0 5px;
  479. border-radius: 20px;
  480. line-height: 20px;
  481. }
  482. }
  483. }
  484. }
  485. }
  486. :deep(.uni-tag){
  487. padding:0px 2px;
  488. height:20px;
  489. line-height: 20px !important;
  490. border-radius: 10px;
  491. }
  492. </style>