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

336 lines
6.9 KiB

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
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
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
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
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
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
5 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.confirmDevelop"/>
  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>
  66. <view class="list">
  67. <view class="item-box"
  68. :key="stepIndex"
  69. v-for="(step, stepIndex) in stepList">
  70. <view class="title">
  71. {{ step.name }}
  72. </view>
  73. <view class="list-box"
  74. :key="cIndex"
  75. v-for="(c, cIndex) in step.workorderItemCheckList">
  76. <view class="title">
  77. {{ c.name }}
  78. </view>
  79. <view class="item-input"
  80. :key="wi"
  81. v-for="(w, wi) in c.workorderParamSteptwoList"
  82. >
  83. <view class="Work-List"
  84. >
  85. <view class="label">
  86. 规格
  87. <!-- {{ w.specs }} -->
  88. </view>
  89. <view class="text">
  90. <input type="text"
  91. :disabled="!isPermission('修改')"
  92. v-model="w.specs"/>
  93. </view>
  94. </view>
  95. <view class="Work-List"
  96. :key="xi"
  97. v-for="(x, xi) in 10"
  98. >
  99. <view class="label">
  100. 参数{{ xi + 1 }}
  101. </view>
  102. <view class="text">
  103. <input type="text"
  104. :disabled="!isPermission('修改')"
  105. v-model="w['param' + (xi + 1)]"/>
  106. </view>
  107. </view>
  108. <view class="Work-List"
  109. >
  110. <view class="label">
  111. 作业员
  112. </view>
  113. <view class="text">
  114. <input type="text"
  115. style="width: 450rpx;"
  116. :disabled="!isPermission('修改')"
  117. v-model="w.operator"/>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <view class="uni-color-btn"
  125. v-if="isPermission('修改')"
  126. @click="submit">
  127. 保存
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. export default {
  133. data() {
  134. return {
  135. id: 0,
  136. StepOne: {},
  137. stepList : [],
  138. index : 1,
  139. title : '',
  140. stepId : 0,
  141. }
  142. },
  143. onLoad(arg) {
  144. this.id = arg.id
  145. this.index = arg.index || 1
  146. this.title = arg.name
  147. this.queryStepTwo()
  148. this.queryTemplateById()
  149. },
  150. methods: {
  151. queryStepTwo() {
  152. this.$api('queryStepTwo', {
  153. templateId: this.id
  154. }, res => {
  155. if (res.code == 200) {
  156. this.StepOne = res.result.workorderGeneralSteptwo || {
  157. currentdate : new Date().getTime()
  158. }
  159. for (let k in this.StepOne) {
  160. if(!this.StepOne[k] || this.StepOne[k] == 'null'){
  161. this.StepOne[k] = ''
  162. }
  163. }
  164. }
  165. })
  166. },
  167. // 根据id获取工单详情
  168. queryTemplateById(){
  169. this.$api('queryTemplateById', {
  170. templateId : this.id
  171. }, res =>{
  172. if(res.code == 200){
  173. let p = res.result.workorderStepList[this.index]
  174. this.stepId = p.id
  175. for(let i = 0;i < p.workorderProcessList.length;i++){
  176. let step = p.workorderProcessList[i]
  177. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  178. let check = step.workorderItemCheckList[j]
  179. if(check.workorderParamSteptwoList.length == 0){
  180. check.workorderParamSteptwoList.push({
  181. processId : check.id,
  182. templateId : this.id,
  183. })
  184. }
  185. }
  186. }
  187. this.stepList = p.workorderProcessList
  188. }
  189. })
  190. },
  191. //工单信息-修改工序参数-工序卡1(选配)
  192. updateParamStepOne(item){
  193. return new Promise((success, error) => {
  194. let data = JSON.parse(JSON.stringify(item))
  195. delete data.updateBy
  196. delete data.updateTime
  197. delete data.createBy
  198. delete data.createTime
  199. for (let k in data) {
  200. if(!data[k] || data[k] == 'null'){
  201. data[k] = ''
  202. }
  203. }
  204. this.$api('updateParamStepTwo', data, res => {
  205. if(res.code == 200){
  206. success(res)
  207. }else{
  208. error(res)
  209. }
  210. })
  211. })
  212. },
  213. async submit(){
  214. console.log(this.stepList);
  215. let StepOne = JSON.parse(JSON.stringify(this.StepOne))
  216. StepOne.stepId = this.stepId
  217. StepOne.templateId = this.id
  218. StepOne.currentdate = this.$dayjs(StepOne.currentdate).format('YYYY-MM-DD')
  219. delete StepOne.updateBy
  220. delete StepOne.updateTime
  221. delete StepOne.createBy
  222. delete StepOne.createTime
  223. // 修改常规参数
  224. this.$api('updateGeneralStepTwo', StepOne, res => {
  225. })
  226. uni.showLoading({
  227. title: '保存中...',
  228. })
  229. // 任务列表
  230. let tasks = []
  231. for(let i = 0;i < this.stepList.length;i++){
  232. let step = this.stepList[i]
  233. for(let j = 0;j < step.workorderItemCheckList.length;j++){
  234. let check = step.workorderItemCheckList[j]
  235. for(let k = 0;k < check.workorderParamSteptwoList.length;k++){
  236. let params = check.workorderParamSteptwoList[k]
  237. // 将请求添加到任务
  238. tasks.push(this.updateParamStepOne(params))
  239. }
  240. }
  241. }
  242. // 等待任务所有完成
  243. await Promise.all(tasks)
  244. uni.showToast({
  245. title: '保存成功',
  246. icon: 'none'
  247. })
  248. setTimeout(uni.navigateBack, 1000, -1)
  249. },
  250. }
  251. }
  252. </script>
  253. <style scoped lang="scss">
  254. .page{
  255. padding-bottom: 200rpx;
  256. .Work-List{
  257. display: flex;
  258. padding: 16rpx 0rpx;
  259. align-items: center;
  260. .label{
  261. width: 200rpx;
  262. flex-shrink: 0;
  263. }
  264. .text{
  265. input{
  266. background-color: #eee;
  267. padding: 10rpx 20rpx;
  268. border-radius: 20rpx;
  269. width: 430rpx;
  270. }
  271. }
  272. }
  273. .info{
  274. padding: 30rpx;
  275. input{
  276. width: 430rpx;
  277. }
  278. }
  279. .list{
  280. padding: 0 30rpx;
  281. .list-box{
  282. padding: 20rpx 0;
  283. padding-left: 40rpx;
  284. .item-input{
  285. padding-left: 40rpx;
  286. .label{
  287. width: 130rpx;
  288. }
  289. }
  290. }
  291. input{
  292. width: 320rpx;
  293. }
  294. }
  295. }
  296. </style>