pdca.vue 7.5 KB

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