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

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