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

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