工单小程序2024-11-20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

287 lines
5.8 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view class="page">
  3. <navbar :title="title" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="info">
  5. <view class="Work-List">
  6. <view class="label">
  7. 部件名
  8. </view>
  9. <view class="text">
  10. <input type="text"
  11. :disabled="!isPermission('修改')"
  12. v-model="StepOne.component"/>
  13. </view>
  14. </view>
  15. <view class="Work-List">
  16. <view class="label">
  17. 研发确认
  18. </view>
  19. <view class="text">
  20. <input type="text"
  21. :disabled="!isPermission('修改')"
  22. v-model="StepOne.confirmDevelop"/>
  23. </view>
  24. </view>
  25. <view class="Work-List">
  26. <view class="label">
  27. 品质确认
  28. </view>
  29. <view class="text">
  30. <input type="text"
  31. :disabled="!isPermission('修改')"
  32. v-model="StepOne.confirmQuality"/>
  33. </view>
  34. </view>
  35. <view class="Work-List">
  36. <view class="label">
  37. 中试确认
  38. </view>
  39. <view class="text">
  40. <input type="text"
  41. :disabled="!isPermission('修改')"
  42. v-model="StepOne.confirmTrial"/>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="list">
  47. <view class="item-box"
  48. :key="stepIndex"
  49. v-for="(step, stepIndex) in stepList">
  50. <view class="title">
  51. {{ step.name }}
  52. </view>
  53. <view class="list-box"
  54. :key="cIndex"
  55. v-for="(c, cIndex) in step.workorderItemCheckList">
  56. <view class="title">
  57. {{ c.name }}
  58. </view>
  59. <view class="item-input"
  60. :key="wi"
  61. v-for="(w, wi) in c.workorderParamSteptwoList"
  62. >
  63. <view class="Work-List"
  64. :key="xi"
  65. v-for="(x, xi) in 10"
  66. >
  67. <view class="label">
  68. 规格{{ xi + 1 }}
  69. </view>
  70. <view class="text">
  71. <input type="text"
  72. :disabled="!isPermission('修改')"
  73. v-model="w['param' + (xi + 1)]"/>
  74. </view>
  75. <view class="text"
  76. v-if="w.specs"
  77. style="margin-left: 20rpx;">
  78. {{ w.specs }}
  79. </view>
  80. </view>
  81. <view class="Work-List"
  82. >
  83. <view class="label">
  84. 作业员
  85. </view>
  86. <view class="text">
  87. <input type="text"
  88. style="width: 450rpx;"
  89. :disabled="!isPermission('修改')"
  90. v-model="w.operator"/>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="uni-color-btn"
  98. v-if="isPermission('修改')"
  99. @click="submit">
  100. 保存
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. id: 0,
  109. StepOne: {},
  110. stepList : [],
  111. index : 1,
  112. title : '',
  113. }
  114. },
  115. onLoad(arg) {
  116. this.id = arg.id
  117. this.index = arg.index || 1
  118. this.title = arg.name
  119. this.queryStepTwo()
  120. this.queryTemplateById()
  121. },
  122. methods: {
  123. queryStepTwo() {
  124. this.$api('queryStepTwo', {
  125. templateId: this.id
  126. }, res => {
  127. if (res.code == 200) {
  128. this.StepOne = res.result.workorderGeneralSteptwo
  129. }
  130. })
  131. },
  132. // 根据id获取工单详情
  133. queryTemplateById(){
  134. this.$api('queryTemplateById', {
  135. templateId : this.id
  136. }, res =>{
  137. if(res.code == 200){
  138. let p = res.result.workorderStepList[this.index]
  139. for(let i = 0;i < p.workorderProcessList.length;i++){
  140. let step = p.workorderProcessList[i]
  141. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  142. let check = step.workorderItemCheckList[j]
  143. if(check.workorderParamSteptwoList.length == 0){
  144. check.workorderParamSteptwoList.push({
  145. processId : check.id,
  146. templateId : this.id,
  147. })
  148. }
  149. }
  150. }
  151. this.stepList = p.workorderProcessList
  152. }
  153. })
  154. },
  155. //工单信息-修改工序参数-工序卡1(选配)
  156. updateParamStepOne(item){
  157. return new Promise((success, error) => {
  158. let data = JSON.parse(JSON.stringify(item))
  159. delete data.updateBy
  160. delete data.updateTime
  161. delete data.createBy
  162. delete data.createTime
  163. for (let k in data) {
  164. if(!data[k] || data[k] == 'null'){
  165. data[k] = ''
  166. }
  167. }
  168. this.$api('updateParamStepTwo', data, res => {
  169. if(res.code == 200){
  170. success(res)
  171. }else{
  172. error(res)
  173. }
  174. })
  175. })
  176. },
  177. async submit(){
  178. console.log(this.stepList);
  179. let StepOne = JSON.parse(JSON.stringify(this.StepOne))
  180. delete StepOne.updateBy
  181. delete StepOne.updateTime
  182. delete StepOne.createBy
  183. delete StepOne.createTime
  184. // 修改常规参数
  185. this.$api('updateGeneralStepTwo', StepOne, res => {
  186. })
  187. uni.showLoading({
  188. title: '保存中...',
  189. })
  190. // 任务列表
  191. let tasks = []
  192. for(let i = 0;i < this.stepList.length;i++){
  193. let step = this.stepList[i]
  194. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  195. let check = step.workorderItemCheckList[j]
  196. for(let k = 0;k < check.workorderParamSteptwoList.length;k++){
  197. let params = check.workorderParamSteptwoList[k]
  198. // 将请求添加到任务
  199. tasks.push(this.updateParamStepOne(params))
  200. }
  201. }
  202. }
  203. // 等待任务所有完成
  204. await Promise.all(tasks)
  205. uni.showToast({
  206. title: '保存成功',
  207. icon: 'none'
  208. })
  209. setTimeout(uni.navigateBack, 1000, -1)
  210. },
  211. }
  212. }
  213. </script>
  214. <style scoped lang="scss">
  215. .page{
  216. padding-bottom: 200rpx;
  217. .Work-List{
  218. display: flex;
  219. padding: 16rpx 0rpx;
  220. align-items: center;
  221. .label{
  222. width: 200rpx;
  223. flex-shrink: 0;
  224. }
  225. .text{
  226. input{
  227. background-color: #eee;
  228. padding: 10rpx 20rpx;
  229. border-radius: 20rpx;
  230. }
  231. }
  232. }
  233. .info{
  234. padding: 30rpx;
  235. input{
  236. width: 430rpx;
  237. }
  238. }
  239. .list{
  240. padding: 0 30rpx;
  241. .list-box{
  242. padding: 20rpx 0;
  243. padding-left: 40rpx;
  244. .item-input{
  245. padding-left: 40rpx;
  246. .label{
  247. width: 130rpx;
  248. }
  249. }
  250. }
  251. input{
  252. width: 320rpx;
  253. }
  254. }
  255. }
  256. </style>