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

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