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

402 lines
8.3 KiB

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