pdca.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. export default {
  66. props: {
  67. // 是否禁用
  68. disabled: {
  69. type: Boolean,
  70. default: false
  71. },
  72. // 详情回显的数据
  73. values: {
  74. type: Object,
  75. default: () => {
  76. return {}
  77. }
  78. },
  79. // 按钮信息 (包过请求的key)
  80. btnInfo: {
  81. type: Object,
  82. default: () => {
  83. return {}
  84. }
  85. },
  86. // 任务详情
  87. missionDetails: {
  88. type: Object,
  89. default: () => {
  90. return {}
  91. }
  92. },
  93. // pdca类型 p 和 pdca
  94. pdcaSetting: {
  95. type: String,
  96. default: 'p'
  97. }
  98. },
  99. data() {
  100. return {
  101. current: 0,
  102. plan: '', // 改善计划
  103. doList: [{record: '', date: ''}], // 执行过程
  104. checkList: [{record: '', date: '', filePath: [] }], // 改善确认
  105. action: '', // 对策处置
  106. // 方案名称显示隐藏
  107. modalVisibile: false
  108. }
  109. },
  110. computed: {
  111. tabItems(){
  112. return this.pdcaSetting === 'p'
  113. ? ['改善计划(P)']
  114. : ['改善计划(P)', '执行过程(D)', '改善确认(C)', '对策处置(A)'];
  115. }
  116. },
  117. created() {
  118. uni.setNavigationBarTitle({
  119. title: '改善计划'
  120. });
  121. // if(this.disabled || this.btnInfo.isEdit) {
  122. this.plan = this.values['plan'] || '';
  123. this.doList = (this.values['do'] && this.values['do'].length > 0)
  124. ? this.getComList(this.values['do'], 'do')
  125. : [{record: '', date: ''}];
  126. this.checkList = (this.values['check'] && this.values['check'].length > 0)
  127. ? this.getComList(this.values['check'], 'check')
  128. : [{record: '', date: '', filePath: [] }];
  129. this.action = this.values['action'] || '';
  130. // }
  131. },
  132. methods: {
  133. onClickItem(e) {
  134. if (this.current !== e.currentIndex) {
  135. this.current = e.currentIndex;
  136. }
  137. },
  138. // 切换方案名称显示隐藏
  139. toggleModalVisibile() {
  140. this.modalVisibile = !this.modalVisibile;
  141. },
  142. // 改善计划/对策处置变化
  143. changeTextare(type, text) {
  144. this[type] = text;
  145. },
  146. // 执行过程变化
  147. changeDoList(list) {
  148. this.doList = list;
  149. },
  150. // 改善确认变化
  151. changeCheckList(list) {
  152. this.checkList = list;
  153. },
  154. // 提交审核/ 暂存(暂存时improveScheme为空)
  155. sure(improveScheme) {
  156. let requestParams = {
  157. improveScheme // 改善方案名称
  158. };
  159. this.btnInfo.params && this.btnInfo.params.map(item => {
  160. if(item.valueKey && !item.isEdit){
  161. requestParams[item.paramsKey] = (
  162. item.isOutvalueKey
  163. ? this.missionDetails
  164. : this.btnInfo
  165. )[item.valueKey];
  166. }else {
  167. switch(item.paramsKey){
  168. case 'taskPlan':
  169. requestParams[item.paramsKey] = this.plan;
  170. break;
  171. case 'taskAction':
  172. requestParams[item.paramsKey] = this.action;
  173. break;
  174. case 'taskDoRequestList':
  175. requestParams[item.paramsKey] = this.doList.map((item, i) => {
  176. return {
  177. taskDoId: i + 1,
  178. taskDoProcess: item.record,
  179. taskDoPlan: item.date
  180. }
  181. });
  182. break;
  183. case 'taskCheckRequestList':
  184. requestParams[item.paramsKey] = this.checkList.map((item, i) => {
  185. return {
  186. taskCheckId: i + 1,
  187. taskCheckProcess: item.record,
  188. taskCheckPlan: item.date,
  189. taskCheckEffect: item.filePath.join(',')
  190. }
  191. });
  192. break;
  193. default:
  194. requestParams[item.paramsKey] = '';
  195. break;
  196. }
  197. }
  198. });
  199. if(improveScheme){ // 提交
  200. requestParams['taskType'] = this.pdcaSetting === 'p' ? 14 : 16;
  201. }else { // 暂存
  202. // requestParams['taskType'] = this.pdcaSetting === 'p' ? 13 : 15;
  203. // 注意暂存的时候接收人是当前登录的账号
  204. requestParams['receiveEmpId'] = uni.getStorageSync('id');
  205. requestParams['receiveEmpName'] = uni.getStorageSync('name');
  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. return newList;
  232. }
  233. },
  234. components: {
  235. uniSegmentedControl,
  236. oneTextarea,
  237. doAndCheck,
  238. modal
  239. }
  240. }
  241. </script>
  242. <style lang="less">
  243. .pdca-page {
  244. height: 100%;
  245. .content {
  246. height: calc(100% - 141.5rpx);
  247. .scroll-y {
  248. height: 100%;
  249. }
  250. }
  251. }
  252. </style>