pdca.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. // console.log('this.btnInfo.params',this.btnInfo.params);
  157. // console.log('this.missionDetails',this.missionDetails);
  158. this.btnInfo.params && this.btnInfo.params.map(item => {
  159. if (item.valueKey && !item.isEdit) {
  160. requestParams[item.paramsKey] = (
  161. item.isOutvalueKey ?
  162. this.missionDetails :
  163. this.btnInfo
  164. )[item.valueKey];
  165. } else {
  166. switch (item.paramsKey) {
  167. case 'taskPlan':
  168. requestParams[item.paramsKey] = this.plan;
  169. break;
  170. case 'taskAction':
  171. requestParams[item.paramsKey] = this.action;
  172. break;
  173. case 'taskDoRequestList':
  174. requestParams[item.paramsKey] = this.doList.map((item, i) => {
  175. return {
  176. taskDoId: i + 1,
  177. taskDoProcess: item.record,
  178. taskDoPlan: item.date
  179. }
  180. });
  181. break;
  182. case 'taskCheckRequestList':
  183. requestParams[item.paramsKey] = this.checkList.map((item, i) => {
  184. return {
  185. taskCheckId: i + 1,
  186. taskCheckProcess: item.record,
  187. taskCheckPlan: item.date,
  188. taskCheckEffect: item.filePath.join(',')
  189. }
  190. });
  191. break;
  192. default:
  193. requestParams[item.paramsKey] = '';
  194. break;
  195. }
  196. }
  197. });
  198. if (improveScheme) { // 提交
  199. requestParams['taskType'] = this.pdcaSetting === 'p' ? 14 : 16;
  200. } else { // 暂存
  201. // requestParams['taskType'] = this.pdcaSetting === 'p' ? 13 : 15;
  202. // 注意暂存的时候接收人是当前登录的账号
  203. requestParams['receiveEmpId'] = uni.getStorageSync('id');
  204. requestParams['receiveEmpName'] = uni.getStorageSync('name');
  205. if ([4, 6].includes(requestParams['taskType'])) {
  206. requestParams['needApproveFlag'] = this.missionDetails.needApproveFlag;
  207. }
  208. }
  209. console.log({'3':requestParams});
  210. this.$emit('comRequest', requestParams);
  211. improveScheme && this.toggleModalVisibile();
  212. },
  213. /**
  214. * 获取相同key 的新数组
  215. * @param {Array} list 原数组
  216. * @param {String} type 类型(如 do、check)
  217. */
  218. getComList(list, type) {
  219. let newList = [];
  220. list.map(item => {
  221. if (type === 'do') {
  222. newList.push({
  223. record: item.taskDoProcess || '', // 记录内容
  224. date: item.taskDoPlan || '' // 计划日期
  225. });
  226. } else if (type === 'check') {
  227. newList.push({
  228. record: item.taskCheckProcess || '', // 记录过程
  229. date: item.taskCheckPlan || '', // 计划日期
  230. filePath: item.taskCheckEffect ? item.taskCheckEffect.split(',') :
  231. [] // 改善效果(图片)
  232. });
  233. }
  234. });
  235. return newList;
  236. }
  237. },
  238. components: {
  239. uniSegmentedControl,
  240. oneTextarea,
  241. doAndCheck,
  242. modal
  243. }
  244. }
  245. </script>
  246. <style lang="less" scoped>
  247. .pdca-page {
  248. height: 100%;
  249. .content {
  250. height: calc(100vh - 125rpx);
  251. .scroll-y {
  252. height: 100%;
  253. }
  254. .bottomBtn {
  255. position: fixed;
  256. bottom: 0;
  257. width: 100%;
  258. height: 75rpx;
  259. line-height: 75rpx;
  260. text-align: center;
  261. font-size: 22.5rpx;
  262. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  263. font-weight: 400;
  264. color: #FFFFFF;
  265. background: #3377FF;
  266. }
  267. }
  268. }
  269. </style>