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

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