checkMap.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="check-map">
  3. <view class="title">请对查核地图进行配置</view>
  4. <view class="check-map-list">
  5. <view class="item"
  6. v-for="(item, index) in checkMap.list"
  7. :class="{disable: item.status === 'disable'}"
  8. @click="detail(item)"
  9. :key="index">
  10. <tm-check-map-list :item="item"></tm-check-map-list>
  11. <view class="btn-group">
  12. <view class="btn"
  13. v-for="(btn, index) in btnGroupArr"
  14. @click.stop="btnClick($event, btn.id, item)"
  15. :key="index">
  16. <image :src="`../../static/icon-${btn.id}${item.status === 'disable'
  17. ? 'dis' : ''}.png`"></image>
  18. <text>{{btn.label}}</text>
  19. </view>
  20. <view class="btn"
  21. @click.stop="btnClick($event, creatIcon(item.status)['id'], item)">
  22. <image :src="`../../static/icon-${creatIcon(item.status)['id']}.png`">
  23. </image>
  24. <text>{{ creatIcon(item.status)['label'] }}</text>
  25. </view>
  26. </view>
  27. <view class="add-img-wrap" v-if="item.status === 'add'">
  28. <image src="../../../static/top-img.png"></image>
  29. <text>新增项</text>
  30. </view>
  31. <view class="dis-img-wrap" v-if="item.status === 'disable'">
  32. <image src="../../../static/disable-img.png"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { mapState } from "vuex";
  40. import {_stopPropagation} from "../../../utils/compatible.js";
  41. const btnGroupArr = [
  42. {id: 'add', label: '新增'},
  43. {id: 'pre', label: '上移'},
  44. {id: 'next', label: '下移'},
  45. ];
  46. export default {
  47. data() {
  48. return {
  49. btnGroupArr,
  50. }
  51. },
  52. computed: {
  53. ...mapState({
  54. theme: state => state.creatingSituations.theme,
  55. checkMap: state => state.creatingSituations.checkMap,
  56. checkRent: state => state.creatingSituations.checkRent,
  57. condition: state => state.creatingSituations.condition,
  58. needReload: state => state.creatingSituations.needReload,
  59. editConfig: state => state.creatingSituations.editConfig
  60. })
  61. },
  62. created:function(){
  63. this.init();
  64. },
  65. methods: {
  66. init: function() {
  67. const {checkedItem} = this.checkRent;
  68. const {depType} = this.condition;
  69. // 编辑的时候不用获取数据
  70. if(this.editConfig && this.editConfig.checkRent && depType === this.editConfig.condition.depType && checkedItem.id === this.editConfig.checkRent.checkedItem.id) {
  71. this.commit('checkMap', this.editConfig.checkMap);
  72. } else if(this.needReload) { // 点击上一步不用获取数据
  73. if(this.theme.id != 2){
  74. //普通+个案
  75. if(!checkedItem.points) return;
  76. let checkPointIds = checkedItem.points.map(({id})=> id);
  77. this.dispatch('checkDeptList', { depType, checkPointIds,conditionIds: this.condition.conditionIds })
  78. .then((data)=> {
  79. if(data) {
  80. let _data = this.checkDep(data);
  81. this.myCommit('list', _data);
  82. }
  83. });
  84. }
  85. if(this.theme.id == 2){
  86. //自查督查
  87. this.dispatch('getPlanSetMap',this.condition.conditionIds)
  88. .then((data)=> {
  89. if(data) {
  90. let _data = this.checkDep(data);
  91. this.myCommit('list', _data);
  92. }
  93. });
  94. }
  95. // 获取新增单位
  96. this.dispatch('deptList', { depType }).then((data)=>{
  97. if(data) this.myCommit('deptList', data);
  98. });
  99. }
  100. },
  101. checkDep: function(list) {
  102. return list.map((item, i)=>{
  103. return {
  104. ...item,
  105. status: 'normal',
  106. pointList: (item.pointList || []).map((ptem)=>{
  107. return {
  108. ...ptem,
  109. selectFlag: true,
  110. itemList: (ptem.itemList || []).map((ntem)=>{
  111. return {
  112. ...ntem,
  113. selectFlag: true
  114. }
  115. })
  116. }
  117. })
  118. }
  119. });
  120. },
  121. creatIcon: function(status) {
  122. let obj = {id: 'jinyong', label: '禁用'};
  123. switch(status) {
  124. case 'add':
  125. obj = {id: 'del', label: '删除'};
  126. break;
  127. case 'disable':
  128. obj = {id: 'qiyong', label: '启用'};
  129. break;
  130. }
  131. return obj;
  132. },
  133. detail: function(item) {
  134. if(item.status === 'disable') return;
  135. this.commit('needReload', false); // 不用新获取数据
  136. this.commit('showCheckMapDetail', true);
  137. this.myCommit('actionItem', item);
  138. },
  139. btnClick: function(e, btnType, item) {
  140. if(item.status === 'disable' && btnType !== 'qiyong') return;
  141. _stopPropagation(e);
  142. switch(btnType) {
  143. case 'add': // 新增
  144. this.commit('needReload', false); // 不用新获取数据
  145. this.commit('showCheckMapAdd', true);
  146. this.myCommit('actionItem', item);
  147. break;
  148. default: // 其他
  149. this.preAndNext(btnType, item);
  150. break;
  151. }
  152. },
  153. preAndNext: function(type, item) {
  154. let arr = [...this.checkMap.list];
  155. let index = arr.findIndex(({id}) => id === item.id);
  156. switch(type) {
  157. case 'pre': // 上移
  158. if(index > 0) {
  159. let pre = arr[index - 1];
  160. arr[index - 1] = item;
  161. arr[index] = pre;
  162. }
  163. break;
  164. case 'next': // 下移
  165. if(index < arr.length - 1) {
  166. let next = arr[index + 1];
  167. arr[index + 1] = item;
  168. arr[index] = next;
  169. }
  170. break;
  171. case 'del': // 删除
  172. arr.splice(index, 1);
  173. break;
  174. case 'jinyong': // 禁用
  175. arr.splice(index, 1);
  176. arr.push({...item, status: 'disable'});
  177. break;
  178. case 'qiyong': // 启用
  179. let _index = arr.findIndex(({status})=>status === 'disable');
  180. arr.splice(index, 1); // 删掉原来的
  181. arr.splice(_index, 0, {...item, status: 'normal'}); // 添加到disable的前面
  182. break;
  183. }
  184. this.myCommit('list', arr);
  185. },
  186. /**
  187. * 更新condition数据
  188. * @param {Object} key 要更新的属性
  189. * @param {Object} value 值
  190. */
  191. myCommit: function(key, value) {
  192. let data = {...this.checkMap};
  193. data[key] = value;
  194. this.commit('checkMap', data);
  195. },
  196. dispatch: function(key, data) {
  197. return this.$store.dispatch({type: 'creatingSituations/commActions', key, data});
  198. },
  199. commit: function(key, data) {
  200. this.$store.commit({type: 'creatingSituations/comChangeState', key, data});
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="less">
  206. .check-map {
  207. .check-map-list {
  208. .btn-group {
  209. display: flex;
  210. flex-direction: row;
  211. padding: 15rpx 0;
  212. width: 100%;
  213. height: 77.5rpx;
  214. background-color: #FAFBFC;
  215. .btn {
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. justify-content: center;
  220. border-right: 1px solid #DADEE6;
  221. flex: 1;
  222. font-size: 17.5rpx;
  223. line-height: 26.25rpx;
  224. color: #7A8599;
  225. &:last-child {
  226. border-right: 0;
  227. }
  228. image {
  229. width: 25rpx;
  230. height: 25rpx;
  231. }
  232. }
  233. }
  234. .dis-img-wrap,
  235. .add-img-wrap {
  236. position: absolute;
  237. top: 18.75rpx;
  238. right: 18.75rpx;
  239. width: 93.75rpx;
  240. height: 93.75rpx;
  241. image {
  242. width: 100%;
  243. height: 100%;
  244. }
  245. }
  246. .add-img-wrap {
  247. top: 0;
  248. right: 0;
  249. width: 100rpx;
  250. height: 35rpx;
  251. text {
  252. position: absolute;
  253. top: 4.37rpx;
  254. left: 28.75rpx;
  255. font-size: 17.5rpx;
  256. line-height: 26.25rpx;
  257. color: #fff;
  258. }
  259. }
  260. &.disable {
  261. .title-wrap {
  262. >text, >view {
  263. color: #B8BECC;
  264. }
  265. }
  266. .content {
  267. text {
  268. color: #B8BECC;
  269. }
  270. }
  271. .btn-group {
  272. .btn {
  273. color: #B8BECC;
  274. &:last-child {
  275. color: #7A8599;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>