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

362 lines
7.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
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" v-model="StepOne.component"/>
  11. </view>
  12. </view>
  13. <view class="Work-List">
  14. <view class="label">
  15. 研发确认
  16. </view>
  17. <view class="text">
  18. <input type="text" v-model="StepOne.comfirmDevelop"/>
  19. </view>
  20. </view>
  21. <view class="Work-List">
  22. <view class="label">
  23. 品质确认
  24. </view>
  25. <view class="text">
  26. <input type="text" v-model="StepOne.comfirmQuality"/>
  27. </view>
  28. </view>
  29. <view class="Work-List">
  30. <view class="label">
  31. 中试确认
  32. </view>
  33. <view class="text">
  34. <input type="text" v-model="StepOne.comfirmTrial"/>
  35. </view>
  36. </view>
  37. <!-- <view class="Work-List">
  38. <view class="label">
  39. 备注
  40. </view>
  41. <view class="text">
  42. <input type="text" v-model="StepOne.remark"/>
  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.workorderParamStepfourList"
  62. >
  63. <view class="image-box">
  64. <view class="image"
  65. :key="xi"
  66. v-for="(x, xi) in 10">
  67. <image
  68. v-if="w['param' + (xi + 1)]"
  69. :src="w['param' + (xi + 1)]"
  70. @click="previewImage([w['param' + (xi + 1)]], 0)"
  71. mode="aspectFill"></image>
  72. <view class="add-image"
  73. v-else
  74. @click="upload(w, 'param' + (xi + 1))">
  75. <uv-icon
  76. size="40rpx"
  77. name="plus"
  78. color="#00000022"
  79. ></uv-icon>
  80. </view>
  81. <view class="delete"
  82. @click="del(w, 'param' + (xi + 1))"
  83. v-if="w['param' + (xi + 1)]">
  84. x
  85. </view>
  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. v-model="w.operator"/>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="uni-color-btn"
  104. @click="submit">
  105. 保存
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. export default {
  111. data() {
  112. return {
  113. id: 0,
  114. StepOne: {},
  115. stepList : [],
  116. index : 1,
  117. title : '',
  118. }
  119. },
  120. onLoad(arg) {
  121. this.id = arg.id
  122. this.index = arg.index || 2
  123. this.title = arg.name
  124. this.queryStepFour()
  125. this.queryTemplateById()
  126. },
  127. methods: {
  128. queryStepFour() {
  129. this.$api('queryStepFour', {
  130. templateId: this.id
  131. }, res => {
  132. if (res.code == 200) {
  133. this.StepOne = res.result.workorderGeneralStepfour
  134. }
  135. })
  136. },
  137. // 根据id获取工单详情
  138. queryTemplateById(){
  139. this.$api('queryTemplateById', {
  140. templateId : this.id
  141. }, res =>{
  142. if(res.code == 200){
  143. let p = res.result.workorderStepList[this.index]
  144. for(let i = 0;i < p.workorderProcessList.length;i++){
  145. let step = p.workorderProcessList[i]
  146. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  147. let check = step.workorderItemCheckList[j]
  148. if(check.workorderParamStepfourList.length == 0){
  149. check.workorderParamStepfourList.push({
  150. processId : check.id,
  151. templateId : this.id,
  152. })
  153. }
  154. }
  155. }
  156. this.stepList = p.workorderProcessList
  157. }
  158. })
  159. },
  160. //工单信息-修改工序参数-工序卡1(选配)
  161. updateParamStepOne(item){
  162. return new Promise((success, error) => {
  163. let data = JSON.parse(JSON.stringify(item))
  164. delete data.updateBy
  165. delete data.updateTime
  166. delete data.createBy
  167. delete data.createTime
  168. for (let k in data) {
  169. if(!data[k] || data[k] == 'null'){
  170. data[k] = ''
  171. }
  172. }
  173. this.$api('updateParamStepFour', data, res => {
  174. if(res.code == 200){
  175. success(res)
  176. }else{
  177. error(res)
  178. }
  179. })
  180. })
  181. },
  182. async submit(){
  183. console.log(this.stepList);
  184. let StepOne = JSON.parse(JSON.stringify(this.StepOne))
  185. delete StepOne.updateBy
  186. delete StepOne.updateTime
  187. delete StepOne.createBy
  188. delete StepOne.createTime
  189. // 修改常规参数
  190. this.$api('updateGeneralStepFour', StepOne, res => {
  191. })
  192. uni.showLoading({
  193. title: '保存中...',
  194. })
  195. // 任务列表
  196. let tasks = []
  197. for(let i = 0;i < this.stepList.length;i++){
  198. let step = this.stepList[i]
  199. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  200. let check = step.workorderItemCheckList[j]
  201. for(let k = 0;k < check.workorderParamStepfourList.length;k++){
  202. let params = check.workorderParamStepfourList[k]
  203. // 将请求添加到任务
  204. tasks.push(this.updateParamStepOne(params))
  205. }
  206. }
  207. }
  208. // 等待任务所有完成
  209. await Promise.all(tasks)
  210. uni.showToast({
  211. title: '保存成功',
  212. icon: 'none'
  213. })
  214. setTimeout(uni.navigateBack, 1000, -1)
  215. },
  216. upload(w, key){
  217. this.$Oss.ossUploadImage({
  218. success : url => {
  219. w[key] = url
  220. this.$forceUpdate()
  221. }
  222. })
  223. },
  224. del(w, key){
  225. w[key] = ''
  226. this.$forceUpdate()
  227. },
  228. // deleteImage(e, w){
  229. // w.fileList.splice(e.index, 1)
  230. // },
  231. // afterRead(e, w){
  232. // let self = this
  233. // e.file.forEach(file => {
  234. // self.$Oss.ossUpload(file.url).then(url => {
  235. // w.fileList.push({
  236. // url
  237. // })
  238. // })
  239. // })
  240. // },
  241. }
  242. }
  243. </script>
  244. <style scoped lang="scss">
  245. .page{
  246. padding-bottom: 200rpx;
  247. .Work-List{
  248. display: flex;
  249. padding: 16rpx 0rpx;
  250. align-items: center;
  251. .label{
  252. width: 200rpx;
  253. flex-shrink: 0;
  254. }
  255. .text{
  256. input{
  257. background-color: #eee;
  258. padding: 10rpx 20rpx;
  259. border-radius: 20rpx;
  260. }
  261. }
  262. }
  263. .info{
  264. padding: 30rpx;
  265. input{
  266. width: 430rpx;
  267. }
  268. }
  269. .list{
  270. padding: 0 30rpx;
  271. .list-box{
  272. padding: 20rpx 0;
  273. padding-left: 40rpx;
  274. .item-input{
  275. padding-left: 40rpx;
  276. .label{
  277. width: 130rpx;
  278. }
  279. .image-box{
  280. display: flex;
  281. width: 100%;
  282. flex-shrink: 0;
  283. flex-wrap: wrap;
  284. .image{
  285. width: 100rpx;
  286. height: 100rpx;
  287. margin: 10rpx;
  288. position: relative;
  289. image{
  290. width: 100%;
  291. height: 100%;
  292. border-radius: 20rpx;
  293. }
  294. .add-image{
  295. width: 100%;
  296. height: 100%;
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. border: 1rpx solid #00000022;
  301. border-radius: 20rpx;
  302. }
  303. .delete{
  304. width: 30rpx;
  305. height: 30rpx;
  306. background-color: #00000066;
  307. color: #fff;
  308. position: absolute;
  309. right: 0;
  310. top: 0;
  311. font-size: 22rpx;
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. input{
  321. width: 320rpx;
  322. }
  323. }
  324. }
  325. </style>