pdca.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="pdca-page">
  3. <uni-segmented-control :current="current" :values="tabItems" @clickItem="onClickItem" style-type="text"
  4. active-color="#3377FF" />
  5. <view class="content">
  6. <scroll-view class="scroll-y" scroll-y="true">
  7. <one-textarea v-if="current === 0" type="plan" :defaultValue="plan"
  8. :disabled="disabled || btnInfo.pDisabled" @changeTextare="changeTextare" />
  9. <do-and-check v-if="current === 1" type="do" :disabled="disabled" :recordList="doList"
  10. @changeRecordList="changeDoList" />
  11. <do-and-check v-if="current === 2" type="check" :disabled="disabled" :recordList="checkList"
  12. :showUploadImg="true" @changeRecordList="changeCheckList" />
  13. <one-textarea v-if="current === 3" type="action" title="对策处置(Action)" label="对策处置"
  14. :defaultValue="action" :disabled="disabled" @changeTextare="changeTextare" />
  15. </scroll-view>
  16. <view class="bottomBtn" @click="goToPrevPage" v-if="disabled">返回改善任务详情</view>
  17. <view class="fixed-buttom-btn" v-if="!disabled">
  18. <view class="btn-text cancle" @click="sure('')">
  19. <text>暂存</text>
  20. </view>
  21. <view class="btn-text" @click="toggleModalVisibile">
  22. <text>提交</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 方案名称modal -->
  27. <modal v-if="modalVisibile" @close="toggleModalVisibile" @sure="sure" />
  28. </view>
  29. </template>
  30. <script>
  31. // 改善任务PDCA
  32. import uniSegmentedControl from "@/components/uni-segmented-control/uni-segmented-control.vue"
  33. import oneTextarea from './pdca-components/one-textarea.vue'
  34. import doAndCheck from './pdca-components/do-and-check.vue'
  35. import modal from './modal.vue'
  36. import {
  37. mapState
  38. } from "vuex";
  39. export default {
  40. props: {
  41. // 是否禁用
  42. disabled: {
  43. type: Boolean,
  44. default: false
  45. },
  46. // 详情回显的数据
  47. values: {
  48. type: Object,
  49. default: () => {
  50. return {}
  51. }
  52. },
  53. // 按钮信息 (包过请求的key)
  54. btnInfo: {
  55. type: Object,
  56. default: () => {
  57. return {}
  58. }
  59. },
  60. // 任务详情
  61. missionDetails: {
  62. type: Object,
  63. default: () => {
  64. return {}
  65. }
  66. },
  67. // pdca类型 p 和 pdca
  68. pdcaSetting: {
  69. type: String,
  70. default: 'p'
  71. }
  72. },
  73. data() {
  74. return {
  75. current: 0,
  76. plan: '', // 改善计划
  77. doList: [{
  78. record: '',
  79. date: ''
  80. }], // 执行过程
  81. checkList: [{
  82. record: '',
  83. date: '',
  84. filePath: []
  85. }], // 改善确认
  86. action: '', // 对策处置
  87. // 方案名称显示隐藏
  88. modalVisibile: false
  89. }
  90. },
  91. computed: {
  92. tabItems() {
  93. return this.pdcaSetting === 'p' ?
  94. ['改善计划(P)'] :
  95. ['改善计划(P)', '执行过程(D)', '改善确认(C)', '对策处置(A)'];
  96. },
  97. ...mapState({
  98. missionDetails: state => state.mission.missionDetails
  99. }),
  100. },
  101. created() {
  102. uni.setNavigationBarTitle({
  103. title: '改善计划'
  104. });
  105. // if(this.disabled || this.btnInfo.isEdit) {
  106. this.plan = this.values['plan'] || '';
  107. this.doList = (this.values['do'] && this.values['do'].length > 0) ?
  108. this.getComList(this.values['do'], 'do') :
  109. [{
  110. record: '',
  111. date: ''
  112. }];
  113. this.checkList = (this.values['check'] && this.values['check'].length > 0) ?
  114. this.getComList(this.values['check'], 'check') :
  115. [{
  116. record: '',
  117. date: '',
  118. filePath: []
  119. }];
  120. this.action = this.values['action'] || '';
  121. // }
  122. },
  123. methods: {
  124. onClickItem(e) {
  125. if (this.current !== e.currentIndex) {
  126. this.current = e.currentIndex;
  127. }
  128. },
  129. // 切换方案名称显示隐藏
  130. toggleModalVisibile() {
  131. this.modalVisibile = !this.modalVisibile;
  132. },
  133. // 改善计划/对策处置变化
  134. changeTextare(type, text) {
  135. this[type] = text;
  136. },
  137. // 执行过程变化
  138. changeDoList(list) {
  139. this.doList = list;
  140. },
  141. goToPrevPage(){
  142. // window.history.back();
  143. uni.navigateBack({
  144. delta: 1
  145. });
  146. },
  147. // 改善确认变化
  148. changeCheckList(list) {
  149. this.checkList = list;
  150. },
  151. // 提交审核/ 暂存(暂存时improveScheme为空)
  152. sure(improveScheme) {
  153. let requestParams = {
  154. improveScheme // 改善方案名称
  155. };
  156. this.btnInfo.params && this.btnInfo.params.map(item => {
  157. if (item.valueKey && !item.isEdit) {
  158. requestParams[item.paramsKey] = (
  159. item.isOutvalueKey ?
  160. this.missionDetails :
  161. this.btnInfo
  162. )[item.valueKey];
  163. } else {
  164. switch (item.paramsKey) {
  165. case 'taskPlan':
  166. requestParams[item.paramsKey] = this.plan;
  167. break;
  168. case 'taskAction':
  169. requestParams[item.paramsKey] = this.action;
  170. break;
  171. case 'taskDoRequestList':
  172. requestParams[item.paramsKey] = this.doList.map((item, i) => {
  173. return {
  174. taskDoId: i + 1,
  175. taskDoProcess: item.record,
  176. taskDoPlan: item.date
  177. }
  178. });
  179. break;
  180. case 'taskCheckRequestList':
  181. requestParams[item.paramsKey] = this.checkList.map((item, i) => {
  182. return {
  183. taskCheckId: i + 1,
  184. taskCheckProcess: item.record,
  185. taskCheckPlan: item.date,
  186. taskCheckEffect: item.filePath.join(',')
  187. }
  188. });
  189. break;
  190. default:
  191. requestParams[item.paramsKey] = '';
  192. break;
  193. }
  194. }
  195. });
  196. if (improveScheme) { // 提交
  197. requestParams['taskType'] = this.pdcaSetting === 'p' ? 14 : 16;
  198. } else { // 暂存
  199. // requestParams['taskType'] = this.pdcaSetting === 'p' ? 13 : 15;
  200. // 注意暂存的时候接收人是当前登录的账号
  201. requestParams['receiveEmpId'] = uni.getStorageSync('id');
  202. requestParams['receiveEmpName'] = uni.getStorageSync('name');
  203. if ([4, 6].includes(requestParams['taskType'])) {
  204. requestParams['needApproveFlag'] = this.missionDetails.needApproveFlag;
  205. }
  206. }
  207. this.$emit('comRequest', requestParams);
  208. improveScheme && this.toggleModalVisibile();
  209. },
  210. /**
  211. * 获取相同key 的新数组
  212. * @param {Array} list 原数组
  213. * @param {String} type 类型(如 do、check)
  214. */
  215. getComList(list, type) {
  216. let newList = [];
  217. list.map(item => {
  218. if (type === 'do') {
  219. newList.push({
  220. record: item.taskDoProcess || '', // 记录内容
  221. date: item.taskDoPlan || '' // 计划日期
  222. });
  223. } else if (type === 'check') {
  224. newList.push({
  225. record: item.taskCheckProcess || '', // 记录过程
  226. date: item.taskCheckPlan || '', // 计划日期
  227. filePath: item.taskCheckEffect ? item.taskCheckEffect.split(',') :
  228. [] // 改善效果(图片)
  229. });
  230. }
  231. });
  232. return newList;
  233. }
  234. },
  235. components: {
  236. uniSegmentedControl,
  237. oneTextarea,
  238. doAndCheck,
  239. modal
  240. }
  241. }
  242. </script>
  243. <style lang="less" scoped>
  244. .pdca-page {
  245. height: 100%;
  246. .content {
  247. height: calc(100vh - 125rpx);
  248. .scroll-y {
  249. height: 100%;
  250. }
  251. .bottomBtn {
  252. position: fixed;
  253. bottom: 0;
  254. width: 100%;
  255. height: 75rpx;
  256. line-height: 75rpx;
  257. text-align: center;
  258. font-size: 22.5rpx;
  259. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  260. font-weight: 400;
  261. color: #FFFFFF;
  262. background: #3377FF;
  263. }
  264. }
  265. }
  266. </style>