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