planList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="planList-page">
  3. <scroll-view class="list-box" scroll-y="true" :style="{'height':listHeight+'rpx'}">
  4. <uni-swipe-action>
  5. <uni-swipe-action-item v-for="(item,index) in planList" :key="index"
  6. :disabled="!item.planFlag"
  7. :threshold="20" :right-options="options" @click="delPlanHandle(item)" >
  8. <view class="item-box" @click.stop="gotoCheckList(false,item)">
  9. <view class="row1">
  10. <text class="title">{{item.name}}</text>
  11. <view class="compeleted-box" v-if="item.isCompeleted">
  12. <text class="compeleted-text">已完成</text>
  13. </view>
  14. <view class="continued-box" v-if="item.isContinued">
  15. <text class="continued-text">进行中</text>
  16. </view>
  17. </view>
  18. <view class="row2">
  19. <text class="TobeDistributed">剩余{{item.toDistribute}}个单位待分配</text>
  20. <text class="startEndTime">起止时间:{{item.startDate}} ~ {{item.endDate}}</text>
  21. </view>
  22. </view>
  23. </uni-swipe-action-item>
  24. </uni-swipe-action>
  25. </scroll-view>
  26. <view class="btn-distribution" @click="gotoCheckList(true, planList[0])" v-if="isShowDistribution">
  27. <text class="btn-text">批量分配</text>
  28. </view>
  29. <modal v-if="showModal" v-on:callback="callback"></modal>
  30. </view>
  31. </template>
  32. <script>
  33. import modal from './components/modal.vue'
  34. import moment from 'moment';
  35. import {
  36. mapState,
  37. mapGetters
  38. } from 'vuex';
  39. export default {
  40. data() {
  41. return {
  42. options: [{
  43. text: '删除',
  44. style: {
  45. backgroundColor: '#F56C6C'
  46. }
  47. }],
  48. situationID: '', //情境id
  49. planList: [], //计划列表
  50. firstFlag: 1, //是否为第一次分配的标志,为1时表示是第一次,弹框提示
  51. isShowDistribution: true, //是否显示批量分配按钮
  52. listHeight: 1125, //列表高度
  53. checkGroupId: 0, // 查核组id
  54. showModal: false,
  55. }
  56. },
  57. computed: {
  58. ...mapState({
  59. ifReloadData: state => {
  60. return !state.planList.ifReloadData ? false : true;
  61. },
  62. })
  63. },
  64. watch: {
  65. ifReloadData(newVal, oldVal) {
  66. if (newVal != oldVal) {
  67. console.log('更新列表');
  68. this.getPlanList();
  69. }
  70. },
  71. },
  72. onLoad({
  73. situationId,
  74. checkGroupId
  75. }) { // situationId:情景id checkGroupId: 查核组id
  76. this.situationID = situationId;
  77. this.checkGroupId = checkGroupId;
  78. },
  79. created: function() {
  80. this.getPlanList();
  81. },
  82. methods: {
  83. delPlanHandle(data){
  84. this.$store.dispatch({
  85. type: 'planList/commActions',
  86. payload: {
  87. key: 'delOutofPlan',
  88. data:data.id
  89. }
  90. }).then(()=>{
  91. this.getPlanList();
  92. })
  93. },
  94. callback(flage) {
  95. this.showModal = false;
  96. if (flage && this.planList.length > 0) {
  97. this.gotoCheckList(true, this.planList[0]);
  98. }
  99. },
  100. getPlanList() {
  101. this.$store.dispatch({
  102. type: 'planList/commActions',
  103. payload: {
  104. key: 'planList',
  105. data: {
  106. situationId: this.situationID
  107. }
  108. }
  109. }).then((data) => {
  110. if (data) {
  111. this.compareTime(data);
  112. this.planList = data.map((item, index) => {
  113. if (item.empList.length != item.toDistribute) {
  114. this.firstFlag = 0;
  115. }
  116. return {
  117. id: item.id,
  118. name: item.name,
  119. startDate: item.startDate,
  120. endDate: item.endDate,
  121. status: item.status,
  122. planFlag:item.planFlag,
  123. situationType: item.situationType,
  124. checkNo: item.checkNo,
  125. isCompeleted: item.status == 3 ? true : false,
  126. isContinued: item.status == 2 ? true : false,
  127. toDistribute: item.toDistribute,
  128. }
  129. });
  130. if (this.firstFlag == 1) {
  131. this.showModal = true;
  132. }
  133. }
  134. });
  135. },
  136. compareTime(planList) {
  137. this.$store.dispatch({
  138. type: "commActions",
  139. key: "getDateStr",
  140. }).then((dateStr) => {
  141. if (dateStr) {
  142. if (planList.some((item) => moment(item.startDate).valueOf() < moment(dateStr)
  143. .valueOf())) {
  144. this.listHeight = 1200;
  145. } else {
  146. this.isShowDistribution = true;
  147. }
  148. }
  149. });
  150. },
  151. /**
  152. * 跳转页面-查核列表
  153. * @param {Boolean} multiple 是否批量编辑
  154. * @param {Number} checkId 查核id
  155. */
  156. gotoCheckList(multiple, currentObj) {
  157. const {
  158. id,
  159. startDate,
  160. endDate,
  161. situationType,
  162. checkNo
  163. } = currentObj;
  164. let _startDate = startDate ? startDate + ' 00:00' : ''; // 计划开始时间
  165. let _endDate = endDate ? endDate + ' 23:59' : ''; // 计划结束时间
  166. //跳转到查核列表
  167. this.$store.commit('planList/comChangeState', {
  168. key: 'ifReloadData',
  169. data: false
  170. });
  171. uni.navigateTo({
  172. url: `/pages/editCheckList/editCheckList?situationId=${this.situationID}&checkId=${id}&checkGroupId=${this.checkGroupId}&startDate=${_startDate}&endDate=${_endDate}&multiple=${multiple}&situationType=${situationType}&checkNo=${checkNo}`
  173. });
  174. }
  175. },
  176. components: {
  177. modal,
  178. }
  179. }
  180. </script>
  181. <style lang="less" scoped>
  182. .planList-page {
  183. height: 100%;
  184. .list-box {
  185. padding-bottom: 80rpx;
  186. .item-box {
  187. width: 100%;
  188. height: 125rpx;
  189. background: #FFFFFF;
  190. border: 0.62rpx solid #DADEE6;
  191. .row1 {
  192. margin-top: 30rpx;
  193. margin-left: 25rpx;
  194. margin-right: 25rpx;
  195. .title {
  196. font-size: 25rpx;
  197. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  198. font-weight: bold;
  199. color: #292C33;
  200. float: left;
  201. }
  202. .compeleted-box {
  203. width: 75rpx;
  204. height: 31.25rpx;
  205. border-radius: 8px;
  206. background: rgba(41, 204, 150, 0.1);
  207. text-align: center;
  208. float: right;
  209. .compeleted-text {
  210. font-size: 17.5rpx;
  211. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  212. font-weight: 500;
  213. color: #29CC96;
  214. line-height: 31.25rpx;
  215. }
  216. }
  217. .continued-box {
  218. width: 75rpx;
  219. height: 31.25rpx;
  220. border-radius: 8px;
  221. background: rgba(255, 204, 102, 0.1);
  222. text-align: center;
  223. float: right;
  224. .continued-text {
  225. width: 75rpx;
  226. height: 31.25rpx;
  227. font-size: 17.5rpx;
  228. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  229. font-weight: 500;
  230. color: #FFAA00;
  231. line-height: 31.25rpx;
  232. }
  233. }
  234. }
  235. .row2 {
  236. margin-left: 25rpx;
  237. margin-top: 75rpx;
  238. margin-right: 25rpx;
  239. .TobeDistributed {
  240. font-size: 20rpx;
  241. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  242. font-weight: 400;
  243. color: #666E80;
  244. float: left;
  245. }
  246. .startEndTime {
  247. font-size: 20rpx;
  248. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  249. font-weight: 400;
  250. color: #666E80;
  251. float: right;
  252. }
  253. }
  254. }
  255. }
  256. .btn-distribution {
  257. width: 750rpx;
  258. height: 75rpx;
  259. background: #3377FF;
  260. position: fixed;
  261. bottom: 0rpx;
  262. .btn-text {
  263. font-size: 22.5rpx;
  264. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  265. font-weight: 400;
  266. color: #FFFFFF;
  267. line-height: 75rpx;
  268. margin-left: 352.5rpx;
  269. }
  270. }
  271. }
  272. </style>