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

429 lines
8.9 KiB

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