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

390 lines
8.0 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
5 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
5 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
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. stepId : 0,
  129. }
  130. },
  131. onLoad(arg) {
  132. this.id = arg.id
  133. this.index = arg.index || 2
  134. this.title = arg.name
  135. this.queryStepFour()
  136. this.queryTemplateById()
  137. },
  138. methods: {
  139. queryStepFour() {
  140. this.$api('queryStepFour', {
  141. templateId: this.id
  142. }, res => {
  143. if (res.code == 200) {
  144. this.StepOne = res.result.workorderGeneralStepfour || {}
  145. for (let k in this.StepOne) {
  146. if(!this.StepOne[k] || this.StepOne[k] == 'null'){
  147. this.StepOne[k] = ''
  148. }
  149. }
  150. }
  151. })
  152. },
  153. // 根据id获取工单详情
  154. queryTemplateById(){
  155. this.$api('queryTemplateById', {
  156. templateId : this.id
  157. }, res =>{
  158. if(res.code == 200){
  159. let p = res.result.workorderStepList[this.index]
  160. this.stepId = p.id
  161. for(let i = 0;i < p.workorderProcessList.length;i++){
  162. let step = p.workorderProcessList[i]
  163. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  164. let check = step.workorderItemCheckList[j]
  165. if(check.workorderParamStepfourList.length == 0){
  166. check.workorderParamStepfourList.push({
  167. processId : check.id,
  168. templateId : this.id,
  169. })
  170. }
  171. }
  172. }
  173. this.stepList = p.workorderProcessList
  174. }
  175. })
  176. },
  177. //工单信息-修改工序参数-工序卡1(选配)
  178. updateParamStepOne(item){
  179. return new Promise((success, error) => {
  180. let data = JSON.parse(JSON.stringify(item))
  181. delete data.updateBy
  182. delete data.updateTime
  183. delete data.createBy
  184. delete data.createTime
  185. for (let k in data) {
  186. if(!data[k] || data[k] == 'null'){
  187. data[k] = ''
  188. }
  189. }
  190. this.$api('updateParamStepFour', data, res => {
  191. if(res.code == 200){
  192. success(res)
  193. }else{
  194. error(res)
  195. }
  196. })
  197. })
  198. },
  199. async submit(){
  200. console.log(this.stepList);
  201. let StepOne = JSON.parse(JSON.stringify(this.StepOne))
  202. StepOne.stepId = this.stepId
  203. StepOne.templateId = this.id
  204. delete StepOne.updateBy
  205. delete StepOne.updateTime
  206. delete StepOne.createBy
  207. delete StepOne.createTime
  208. // 修改常规参数
  209. this.$api('updateGeneralStepFour', StepOne, res => {
  210. })
  211. uni.showLoading({
  212. title: '保存中...',
  213. })
  214. // 任务列表
  215. let tasks = []
  216. for(let i = 0;i < this.stepList.length;i++){
  217. let step = this.stepList[i]
  218. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  219. let check = step.workorderItemCheckList[j]
  220. for(let k = 0;k < check.workorderParamStepfourList.length;k++){
  221. let params = check.workorderParamStepfourList[k]
  222. // 将请求添加到任务
  223. tasks.push(this.updateParamStepOne(params))
  224. }
  225. }
  226. }
  227. // 等待任务所有完成
  228. await Promise.all(tasks)
  229. uni.showToast({
  230. title: '保存成功',
  231. icon: 'none'
  232. })
  233. setTimeout(uni.navigateBack, 1000, -1)
  234. },
  235. upload(w, key){
  236. if(!this.isPermission('修改')){
  237. return
  238. }
  239. this.$Oss.ossUploadImage({
  240. success : url => {
  241. w[key] = url
  242. this.$forceUpdate()
  243. }
  244. })
  245. },
  246. del(w, key){
  247. if(!this.isPermission('修改')){
  248. return
  249. }
  250. w[key] = ''
  251. this.$forceUpdate()
  252. },
  253. // deleteImage(e, w){
  254. // w.fileList.splice(e.index, 1)
  255. // },
  256. // afterRead(e, w){
  257. // let self = this
  258. // e.file.forEach(file => {
  259. // self.$Oss.ossUpload(file.url).then(url => {
  260. // w.fileList.push({
  261. // url
  262. // })
  263. // })
  264. // })
  265. // },
  266. }
  267. }
  268. </script>
  269. <style scoped lang="scss">
  270. .page{
  271. padding-bottom: 200rpx;
  272. .Work-List{
  273. display: flex;
  274. padding: 16rpx 0rpx;
  275. align-items: center;
  276. .label{
  277. width: 200rpx;
  278. flex-shrink: 0;
  279. }
  280. .text{
  281. input{
  282. background-color: #eee;
  283. padding: 10rpx 20rpx;
  284. border-radius: 20rpx;
  285. }
  286. }
  287. }
  288. .info{
  289. padding: 30rpx;
  290. input{
  291. width: 430rpx;
  292. }
  293. }
  294. .list{
  295. padding: 0 30rpx;
  296. .list-box{
  297. padding: 20rpx 0;
  298. padding-left: 40rpx;
  299. .item-input{
  300. padding-left: 40rpx;
  301. .label{
  302. width: 130rpx;
  303. }
  304. .image-box{
  305. display: flex;
  306. width: 100%;
  307. flex-shrink: 0;
  308. flex-wrap: wrap;
  309. .image{
  310. width: 100rpx;
  311. height: 100rpx;
  312. margin: 10rpx;
  313. position: relative;
  314. image{
  315. width: 100%;
  316. height: 100%;
  317. border-radius: 20rpx;
  318. }
  319. .add-image{
  320. width: 100%;
  321. height: 100%;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. border: 1rpx solid #00000022;
  326. border-radius: 20rpx;
  327. }
  328. .delete{
  329. width: 30rpx;
  330. height: 30rpx;
  331. background-color: #00000066;
  332. color: #fff;
  333. position: absolute;
  334. right: 0;
  335. top: 0;
  336. font-size: 22rpx;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. input{
  346. width: 320rpx;
  347. }
  348. }
  349. }
  350. </style>