handleReport.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="工序报工"
  8. @clickLeft="back"
  9. >
  10. </uni-nav-bar>
  11. <view class="report-view">
  12. <view class="card-list">
  13. <view class="list-item" v-for="(item, index) in msgList" :key='index'>
  14. <view class="label">{{item.label}}</view>
  15. <view v-if="item.type === 'checked'">
  16. <u-checkbox-group @change="(e) => formData[item.key] = e[0] || ''">
  17. <u-checkbox
  18. icon-size='30'
  19. size='30'
  20. name="1"
  21. ></u-checkbox>
  22. </u-checkbox-group>
  23. </view>
  24. <view v-else-if="item.type === 'inp'" >
  25. <input class="uni-input" v-model="formData[item.key]" placeholder="请输入" />
  26. </view>
  27. <view class="text-primary" v-else-if="item.type === 'trash'" @click='handleClick(item)'>{{formData[item.key] || '点击更新'}}</view>
  28. <view class="text-primary" v-else-if="item.type=== 'msg'" @click='handleMsg(item)'>{{processesInfo[item.key] || '查看'}}</view>
  29. <view v-else-if="item.type=== 'show'" >{{formData[item.key]}}</view>
  30. <view v-else :class="{'warning': item.isWarn && !Number.isNaN(+processesInfo[item.key]) && (processesInfo[item.key] < 0)}">{{processesInfo[item.key]}}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="footer">
  35. <button type="primary" @click="handleReport">报工</button>
  36. </view>
  37. <editDialog ref='editDialogRef'/>
  38. <msgDialog ref='msgDialogRef' :processesInfo='processesInfo'/>
  39. </view>
  40. </template>
  41. <script>
  42. import { report } from "@/api/report/index"
  43. import editDialog from "./components/editDialog.vue"
  44. import msgDialog from "./components/msgDialog.vue"
  45. import {add} from "@/utils/math"
  46. export default {
  47. components:{editDialog, msgDialog},
  48. data(){
  49. return {
  50. msgList:[
  51. { label: '序号', key: 'vornr'},
  52. { label: '工序名称', key: 'processes'},
  53. { label: '已合格', key: 'lmnga'},
  54. { label: '已废品', key: 'xmnga', type: 'msg'},
  55. { label: '在制品', key: 'workProgress', isWarn: true},
  56. { label: '无成本报工', key: 'notGs', type:'checked'},
  57. { label: '本次合格', key: 'lmnga', type: 'inp'},
  58. { label: '设备号', key: 'equipId', type: 'inp'},
  59. { label: '报工批次', key: 'reciverBatch', type: 'inp'},
  60. { label: '混合料密度', key: 'matnrDensity', type: 'inp'},
  61. { label: '混炼TEP', key: 'workTemp', type: 'inp'},
  62. { label: '操作工', key: 'actionName', type: 'inp'},
  63. { label: '废品', key: 'xmnga', type: 'trash'},
  64. { label: '检查工', key: 'checkName', type: 'inp'},
  65. { label: '设备次数', key: 'equipNum', type: 'inp'},
  66. { label: '工艺曲线', key: 'processCurve', type: 'inp'},
  67. { label: '返修', key: 'upmnga', type: 'trash'},
  68. { label: '让步', key: 'cmnga', type: 'trash'},
  69. { label: '改型', key: 'umnga', type: 'trash'},
  70. { label: '返回料', key: 'remnga', type: 'inp'},
  71. { label: '反工料', key: 'rmnga', type: 'inp'},
  72. { label: '备注', key: 'workDesc', type: 'inp'},
  73. { label: '已返修', key: 'upmnga', type: 'msg'},
  74. { label: '已让步', key: 'cmnga', type: 'msg'},
  75. { label: '已改型', key: 'umnga', type: 'msg'},
  76. { label: '加工要求', key: 'ltxa1Desc'},
  77. // { label: '工序描述', key: 'ltxa1', type: 'inp'},
  78. { label: '工序控制码', key: 'steus'},
  79. { label: '废品JSON', key: 'xmngaJson', type: 'show'},
  80. { label: '让步JOSN', key: 'cmngaJson', type: 'show'},
  81. { label: '返修JOSN', key: 'upmngaJson', type: 'show'},
  82. { label: '改型JOSN', key: 'umngaJson', type: 'show'},
  83. { label: '模孔数', key: 'dieHole', type: 'inp'},
  84. // { label: '批量收货数', key: 'shsl', type: 'inp'},
  85. { label: '压力', key: 'yl', type: 'inp'},
  86. { label: '料浆粘度', key: 'ljnd', type: 'inp'},
  87. ],
  88. processesInfo:{},
  89. formData:{
  90. workType:'1',
  91. omnga:0,
  92. vornrId:"",
  93. notGs:"",
  94. lmnga:"",
  95. equipId:"",
  96. reciverBatch:"",
  97. matnrDensity:"",
  98. workTemp:"",
  99. actionName:"",
  100. xmnga:"",
  101. checkName:"",
  102. equipNum:"",
  103. processCurve:"",
  104. upmnga:"",
  105. cmnga:"",
  106. umnga:"",
  107. remnga:"",
  108. rmnga:"",
  109. workDesc:"",
  110. ltxa1Desc:"",
  111. ltxa1:"",
  112. steus:"",
  113. xmngaJson:"",
  114. cmngaJson:"",
  115. umngaJson:"",
  116. upmngaJson:"",
  117. dieHole:"",
  118. shsl:"",
  119. yl:"",
  120. ljnd:"",
  121. }
  122. }
  123. },
  124. onLoad({data}){
  125. data = JSON.parse(data)
  126. this.processesInfo = data
  127. this.formData.vornrId = data.id
  128. this.formData.vornr = data.vornr
  129. this.formData.ltxa1 = data.processesDesc
  130. this.formData.aufnr = data.aufnr
  131. },
  132. methods:{
  133. handleClick(item){
  134. this.$refs.editDialogRef.open(item.key, this.formData, (data) => {
  135. this.formData.xmngaJson = data.xmngaList.length ? JSON.stringify(data.xmngaList.map(item => ({
  136. first: item.first,
  137. last: item.last.trim()
  138. }))) : ''
  139. this.formData.cmngaJson = data.cmngaList.length ? JSON.stringify(data.cmngaList.map(item => ({
  140. first: item.first,
  141. last: item.last.trim()
  142. }))) : ''
  143. this.formData.umngaJson = data.umngaList.length ? JSON.stringify(data.umngaList.map(item => ({
  144. first: item.first,
  145. last: item.last.trim()
  146. }))) : ''
  147. this.formData.upmngaJson = data.upmngaList.length ? JSON.stringify(data.upmngaList.map(item => ({
  148. first: item.first,
  149. last: item.last.trim()
  150. }))) : ''
  151. this.formData.xmnga = data.xmngaList.reduce((sum, cur) => sum + Number(cur.first), 0) || ''
  152. this.formData.cmnga = data.cmngaList.reduce((sum, cur) => sum + Number(cur.first), 0)|| ''
  153. this.formData.umnga = data.umngaList.reduce((sum, cur) => sum + Number(cur.first), 0)|| ''
  154. this.formData.upmnga = data.upmngaList.reduce((sum, cur) => sum + Number(cur.first), 0)|| ''
  155. })
  156. },
  157. handleMsg(item){
  158. this.$refs.msgDialogRef.open(item.key, this.processesInfo)
  159. },
  160. handleReport(){
  161. if(this.formData.lmnga === '0' || this.formData.lmnga === 0){
  162. return uni.showToast({
  163. icon:'none',
  164. title:'本次合格不能为0'
  165. })
  166. }
  167. if(this.formData.xmnga === '0' || this.formData.xmnga === 0){
  168. return uni.showToast({
  169. icon:'none',
  170. title:'废品不能为0'
  171. })
  172. }
  173. if(this.formData.lmnga + this.formData.xmnga + this.formData.upmnga + this.formData.cmnga + this.formData.umnga <= 0){
  174. return uni.showToast({
  175. icon:'none',
  176. title: '不满足报工条件,请完善数据!'
  177. })
  178. }
  179. const _this = this
  180. uni.showModal({
  181. title: `确认报工?`,
  182. content: '',
  183. confirmText: '确认',
  184. success: function (res) {
  185. if (res.confirm) {
  186. const map = {
  187. KG:1,
  188. G: 0.001,
  189. TON: 1000
  190. }
  191. let sum =add(add(_this.formData.lmnga || 0 , _this.formData.cmnga || 0), _this.formData.umnga || 0)
  192. if(['KG', 'G', 'TON'].includes(_this.processesInfo.meins)){
  193. _this.formData.totalNtgew = map[_this.processesInfo.meins] * sum
  194. }else{
  195. _this.formData.totalNtgew = map[_this.processesInfo.gewei] * sum
  196. }
  197. if(_this.formData.upmnga && !_this.formData.lmnga && !_this.formData.xmnga && !_this.formData.cmnga && !_this.formData.umnga){
  198. _this.formData.repair = 1
  199. }else{
  200. _this.formData.repair = 0
  201. }
  202. const userInfo = uni.getStorageSync('userInfo')
  203. if(userInfo?.id){
  204. _this.formData.crtUser = userInfo.id
  205. _this.formData.crtName = userInfo.name
  206. }
  207. // 默认值/、
  208. _this.formData.xmngaJson = _this.formData.xmngaJson || JSON.stringify([{first:'', last:''}])
  209. _this.formData.cmngaJson = _this.formData.cmngaJson || JSON.stringify([{first:'', last:''}])
  210. _this.formData.umngaJson = _this.formData.umngaJson || JSON.stringify([{first:'', last:''}])
  211. _this.formData.upmngaJson = _this.formData.upmngaJson || JSON.stringify([{first:'', last:''}])
  212. _this.formData.xmnga = _this.formData.xmnga || 0
  213. _this.formData.upmnga = _this.formData.upmnga || 0
  214. _this.formData.cmnga = _this.formData.cmnga || 0
  215. _this.formData.umnga = _this.formData.umnga || 0
  216. _this.formData.lmnga = _this.formData.lmnga || 0
  217. report(_this.formData).then(res => {
  218. if(res === 0){
  219. uni.showModal({
  220. title: `当前为结账期间,禁止报工!`,
  221. content: '',
  222. confirmText: '确认',
  223. showCancel: false
  224. })
  225. return
  226. }
  227. uni.showToast({
  228. title:'报工成功!'
  229. })
  230. setTimeout(() => {
  231. uni.navigateBack({
  232. delta:1
  233. })
  234. }, 1500);
  235. }).catch(err => {
  236. uni.showToast({
  237. title: err,
  238. icon: 'none'
  239. })
  240. })
  241. }
  242. }
  243. })
  244. },
  245. },
  246. };
  247. </script>
  248. <style lang='scss' scoped>
  249. .mainBox{
  250. background: $page-bg;
  251. height: 100vh;
  252. overflow: auto;
  253. }
  254. .report-view{
  255. padding: 16rpx;
  256. font-size: $uni-font-size-lg;
  257. }
  258. .warning{
  259. color: red
  260. }
  261. .card-list{
  262. padding: 30rpx;
  263. background: #fff;
  264. border-radius: 16rpx;
  265. /deep/.list-item{
  266. display: flex;
  267. justify-content: space-between;
  268. align-items: center;
  269. padding: 16rpx 0;
  270. border-bottom: 1rpx solid #ccc;
  271. font-size: $uni-font-size-lg;
  272. input{
  273. font-size: $uni-font-size-lg;
  274. text-align: right;
  275. }
  276. /deep/.uni-data-checklist .checkbox__inner{
  277. width: 40rpx;
  278. height: 40rpx;
  279. }
  280. }
  281. }
  282. .footer{
  283. height: 100rpx;
  284. button{
  285. font-size: $uni-font-size-lg;
  286. position: fixed;
  287. bottom: 0;
  288. left: 0;
  289. right: 0;
  290. }
  291. }
  292. </style>