工单小程序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.

311 lines
6.3 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
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
5 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
5 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
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
5 months ago
6 months ago
5 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
5 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. >
  65. <view class="label">
  66. 规格
  67. <!-- {{ w.specs }} -->
  68. </view>
  69. <view class="text">
  70. <input type="text"
  71. :disabled="!isPermission('修改')"
  72. v-model="w.specs"/>
  73. </view>
  74. </view>
  75. <view class="Work-List"
  76. :key="xi"
  77. v-for="(x, xi) in 10"
  78. >
  79. <view class="label">
  80. 参数{{ xi + 1 }}
  81. </view>
  82. <view class="text">
  83. <input type="text"
  84. :disabled="!isPermission('修改')"
  85. v-model="w['param' + (xi + 1)]"/>
  86. </view>
  87. </view>
  88. <view class="Work-List"
  89. >
  90. <view class="label">
  91. 作业员
  92. </view>
  93. <view class="text">
  94. <input type="text"
  95. style="width: 450rpx;"
  96. :disabled="!isPermission('修改')"
  97. v-model="w.operator"/>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="uni-color-btn"
  105. v-if="isPermission('修改')"
  106. @click="submit">
  107. 保存
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. export default {
  113. data() {
  114. return {
  115. id: 0,
  116. StepOne: {},
  117. stepList : [],
  118. index : 1,
  119. title : '',
  120. stepId : 0,
  121. }
  122. },
  123. onLoad(arg) {
  124. this.id = arg.id
  125. this.index = arg.index || 1
  126. this.title = arg.name
  127. this.queryStepTwo()
  128. this.queryTemplateById()
  129. },
  130. methods: {
  131. queryStepTwo() {
  132. this.$api('queryStepTwo', {
  133. templateId: this.id
  134. }, res => {
  135. if (res.code == 200) {
  136. this.StepOne = res.result.workorderGeneralSteptwo || {}
  137. for (let k in this.StepOne) {
  138. if(!this.StepOne[k] || this.StepOne[k] == 'null'){
  139. this.StepOne[k] = ''
  140. }
  141. }
  142. }
  143. })
  144. },
  145. // 根据id获取工单详情
  146. queryTemplateById(){
  147. this.$api('queryTemplateById', {
  148. templateId : this.id
  149. }, res =>{
  150. if(res.code == 200){
  151. let p = res.result.workorderStepList[this.index]
  152. this.stepId = p.id
  153. for(let i = 0;i < p.workorderProcessList.length;i++){
  154. let step = p.workorderProcessList[i]
  155. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  156. let check = step.workorderItemCheckList[j]
  157. if(check.workorderParamSteptwoList.length == 0){
  158. check.workorderParamSteptwoList.push({
  159. processId : check.id,
  160. templateId : this.id,
  161. })
  162. }
  163. }
  164. }
  165. this.stepList = p.workorderProcessList
  166. }
  167. })
  168. },
  169. //工单信息-修改工序参数-工序卡1(选配)
  170. updateParamStepOne(item){
  171. return new Promise((success, error) => {
  172. let data = JSON.parse(JSON.stringify(item))
  173. delete data.updateBy
  174. delete data.updateTime
  175. delete data.createBy
  176. delete data.createTime
  177. for (let k in data) {
  178. if(!data[k] || data[k] == 'null'){
  179. data[k] = ''
  180. }
  181. }
  182. this.$api('updateParamStepTwo', data, res => {
  183. if(res.code == 200){
  184. success(res)
  185. }else{
  186. error(res)
  187. }
  188. })
  189. })
  190. },
  191. async submit(){
  192. console.log(this.stepList);
  193. let StepOne = JSON.parse(JSON.stringify(this.StepOne))
  194. StepOne.stepId = this.stepId
  195. StepOne.templateId = this.id
  196. delete StepOne.updateBy
  197. delete StepOne.updateTime
  198. delete StepOne.createBy
  199. delete StepOne.createTime
  200. // 修改常规参数
  201. this.$api('updateGeneralStepTwo', StepOne, res => {
  202. })
  203. uni.showLoading({
  204. title: '保存中...',
  205. })
  206. // 任务列表
  207. let tasks = []
  208. for(let i = 0;i < this.stepList.length;i++){
  209. let step = this.stepList[i]
  210. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  211. let check = step.workorderItemCheckList[j]
  212. for(let k = 0;k < check.workorderParamSteptwoList.length;k++){
  213. let params = check.workorderParamSteptwoList[k]
  214. // 将请求添加到任务
  215. tasks.push(this.updateParamStepOne(params))
  216. }
  217. }
  218. }
  219. // 等待任务所有完成
  220. await Promise.all(tasks)
  221. uni.showToast({
  222. title: '保存成功',
  223. icon: 'none'
  224. })
  225. setTimeout(uni.navigateBack, 1000, -1)
  226. },
  227. }
  228. }
  229. </script>
  230. <style scoped lang="scss">
  231. .page{
  232. padding-bottom: 200rpx;
  233. .Work-List{
  234. display: flex;
  235. padding: 16rpx 0rpx;
  236. align-items: center;
  237. .label{
  238. width: 200rpx;
  239. flex-shrink: 0;
  240. }
  241. .text{
  242. input{
  243. background-color: #eee;
  244. padding: 10rpx 20rpx;
  245. border-radius: 20rpx;
  246. width: 430rpx;
  247. }
  248. }
  249. }
  250. .info{
  251. padding: 30rpx;
  252. input{
  253. width: 430rpx;
  254. }
  255. }
  256. .list{
  257. padding: 0 30rpx;
  258. .list-box{
  259. padding: 20rpx 0;
  260. padding-left: 40rpx;
  261. .item-input{
  262. padding-left: 40rpx;
  263. .label{
  264. width: 130rpx;
  265. }
  266. }
  267. }
  268. input{
  269. width: 320rpx;
  270. }
  271. }
  272. }
  273. </style>