process.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="page">
  3. <tn-nav-bar fixed>工序追溯</tn-nav-bar>
  4. <view class="" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
  5. <view v-if="!errorMsg && !process" class="tn-border-solid">
  6. <view class="tn-flex tn-flex-col-bottom tn-margin">
  7. <view class="tn-flex-3 align-content-item tn-text-center ">
  8. <view class="content tn-flex tn-flex-direction-row tn-flex-col-center">
  9. <view class="content__title">产品二维码:</view>
  10. <view class="content__data tn-flex-1">
  11. <tn-input v-model="qrCode" type="text" placeholder="请扫描产品二维码" border :height="60" >
  12. </tn-input>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="tn-flex-1 align-content-item tn-text-right">
  17. <tn-button backgroundColor="#01BEFF" fontColor="tn-color-white" icon="tn-icon-scan" @click="openScan">
  18. <span class="tn-icon-scan tn-margin-right-xs"></span>扫码
  19. </tn-button>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-if="!errorMsg && !process" >
  24. <view class="tn-margin">
  25. <tn-button :shadow="true" width="100%" backgroundColor="#01BEFF" fontColor="#FFFFFF" margin="10rpx 0" @click="getProductProcess">开始追溯</tn-button>
  26. </view>
  27. <template v-if="processId && processStats">
  28. <view class="list tn-border-solid">
  29. <view class="tn-flex tn-border-solid-bottom tn-main-gradient-blue--reverse">
  30. <view class="tn-flex-2 tn-text-center">待加工</view>
  31. <view class="tn-flex-2 tn-text-center">已加工</view>
  32. <view class="tn-flex-2 tn-text-center">不良品数</view>
  33. <view class="tn-flex-2 tn-text-center">良品率</view>
  34. </view>
  35. <block v-for="(item,index) in processStats ">
  36. <view class="tn-flex tn-border-solid-bottom" >
  37. <view class="tn-flex-2 tn-text-center">{{item.unfinishedCount}}</view>
  38. <view class="tn-flex-2 tn-text-center">{{item.completedCount}}</view>
  39. <view class="tn-flex-2 tn-text-center">{{item.errorCount}}</view>
  40. <view class="tn-flex-2 tn-text-center">{{item.yield}}</view>
  41. </view>
  42. </block>
  43. </view>
  44. </template>
  45. </view>
  46. <view v-if="errorMsg" class="tn-padding tn-bg-white tn-border-solid-top">
  47. <tn-empty icon="../../../static/image/cart.jpg" :text="errorMsg" :imgWidth="200" :imgHeight="200" class="tn-margin-top-xl "></tn-empty>
  48. <tn-button :shadow="true" width="100%" backgroundColor="#01BEFF" fontColor="#FFFFFF" margin="30rpx 0" @click="initProcess">返回</tn-button>
  49. </view>
  50. <view v-if="process">
  51. <!-- <tn-tabs :list="[{name:'产品信息'}]" :current="0" ></tn-tabs> -->
  52. <view class="tn-margin tn-border-solid-top tn-no-margin-top">
  53. <tn-list-cell>
  54. <view class="list-icon-text">
  55. <view class="list__left">
  56. <view class="list__left__text tn-color-gray--dark">产品名称</view>
  57. </view>
  58. <view class="list__right">{{product?product.productName:productModel.productName}}</view>
  59. </view>
  60. </tn-list-cell>
  61. <tn-list-cell>
  62. <view class="list-icon-text">
  63. <view class="list__left">
  64. <view class="list__left__text tn-color-gray--dark">产品型号</view>
  65. </view>
  66. <view class="list__right">{{product?product.productModel:productModel.productModel}}</view>
  67. </view>
  68. </tn-list-cell>
  69. <tn-list-cell>
  70. <view class="list-icon-text">
  71. <view class="list__left">
  72. <view class="list__left__text tn-color-gray--dark">二维码编号</view>
  73. </view>
  74. <view class="list__right">{{qrCode}}</view>
  75. </view>
  76. </tn-list-cell>
  77. <tn-list-cell>
  78. <view class="list-icon-text">
  79. <view class="list__left">
  80. <view class="list__left__text tn-color-gray--dark">产品状态</view>
  81. </view>
  82. <view class="list__right">{{product?(product.status==1?'维修中':product.status==2?'已下线':product.status==3?'已入库':product.status==0?'作废':product.status==-1?'生产中':''):'未建档'}}</view>
  83. </view>
  84. </tn-list-cell>
  85. <tn-list-cell>
  86. <view class="list-icon-text">
  87. <view class="list__left">
  88. <view class="list__left__text tn-color-gray--dark">当前工序</view>
  89. </view>
  90. <view class="list__right">{{process.processName}}({{process.processCode}})</view>
  91. </view>
  92. </tn-list-cell>
  93. </view>
  94. <template v-if="process.isRetrospect==1">
  95. <tn-tabs :list="[{name:'工序追溯'}]" :current="0" ></tn-tabs>
  96. <view class="tn-margin tn-padding-left tn-padding-right tn-border-solid-top tn-no-margin-top">
  97. <template v-for="(item, index) in process.details">
  98. <tn-form-item :label="item.processItemName" :labelWidth="200" labelPosition="left" required >
  99. <template v-if="item.valueType==1" >
  100. <tn-radio-group v-model="item.value" style="display: flex;justify-content: flex-end;">
  101. <tn-radio name="OK">OK</tn-radio>
  102. <tn-radio name="NG" >NG</tn-radio>
  103. </tn-radio-group>
  104. </template>
  105. <template v-else>
  106. <tn-input type="text" v-model="item.value" :placeholder="'请输入'+item.processItemName" inputAlign="right"></tn-input>
  107. </template>
  108. </tn-form-item>
  109. <!-- <el-form-item label="研究方向" :prop="'list.'+index+'.name'" :rules="{required:true,message:'研究方向不能为空',trigger:'blur'}">
  110. <el-input v-model="item.name" placeholder="请输入研究方向" />
  111. </el-form-item> -->
  112. </template>
  113. <tn-form-item label="上传图片" prop="images" :labelWidth="200" :required="true" v-if="isReworkRecord">
  114. <tn-image-upload :fileList="images" :action="action" :header="header" @on-success="imageUploadChange" slot="right"></tn-image-upload>
  115. </tn-form-item>
  116. <tn-form-item label="问题描述" prop="problemDesc" :labelWidth="200" labelPosition="left" required v-if="isReworkRecord">
  117. <tn-input type="text" v-model="problemDesc" placeholder="请输入问题描述" inputAlign="right"></tn-input>
  118. </tn-form-item>
  119. </view>
  120. </template>
  121. <view class="tn-flex tn-margin" v-if="process.isPhotograph==0">
  122. <view class="tn-flex-1 tn-padding-sm">
  123. <tn-button :shadow="true" width="100%" backgroundColor="tn-bg-teal" fontColor="#FFFFFF" @click="initProcess" margin="10rpx 0">返回</tn-button>
  124. </view>
  125. <view class="tn-flex-1 tn-padding-sm">
  126. <tn-button :shadow="true" width="100%" backgroundColor="#01BEFF" fontColor="#FFFFFF" @click="submit" margin="10rpx 0">提交</tn-button>
  127. </view>
  128. </view>
  129. <view v-else>
  130. <view class="tn-padding-sm tn-margin-top tn-color-red">当前工序为拍照工序,请通过相机作业</view>
  131. <view class="tn-padding-sm">
  132. <tn-button :shadow="true" width="100%" backgroundColor="tn-bg-teal" fontColor="#FFFFFF" @click="initProcess" margin="10rpx 0">返回</tn-button>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <script setup>
  140. export default {
  141. data(){
  142. return {
  143. labelWidth: 170,
  144. action: this.api.apiHost()+"wx/communal/api/upload",
  145. header:{
  146. 'Authorization':'Basic d3hBcHBsZXQ6d3hBcHBsZXRfc2VjcmV0',
  147. 'tenant_id':'000000',
  148. 'Blade-Auth': "bearer "+this.api.getToken(),
  149. },
  150. qrCode:'',
  151. errorMsg:'',
  152. product:'',
  153. productModel:'',
  154. process:'',
  155. isReworkRecord:false,
  156. images:[],
  157. problemDesc:'',
  158. processStats:[],
  159. processId:'',
  160. productModelId:'',
  161. }
  162. },
  163. onLoad(options){
  164. if(options.processId){
  165. this.processId = options.processId
  166. this.productModelId = options.productModelId
  167. this.productProcessReport()
  168. }
  169. },
  170. onShow(){
  171. },
  172. methods: {
  173. openScan(){
  174. // 允许从相机和相册扫码
  175. let that = this;
  176. uni.scanCode({
  177. success: function (res) {
  178. that.qrCode = res.result
  179. that.getProductProcess()
  180. }
  181. });
  182. },
  183. imageUploadChange(data,index,datas){
  184. this.images = datas;
  185. },
  186. getProductProcess(){
  187. if(!this.qrCode){
  188. this.api.toast("请填写产品二维码")
  189. return;
  190. }
  191. let that = this,
  192. url = "wx/product/api/getProductProcess",
  193. params = {
  194. qrCode:that.qrCode,
  195. processId:that.processId
  196. }
  197. that.api.request(url, params,"get").then((res) => {
  198. console.log(res)
  199. that.product = res.product
  200. that.productModel = res.productModel
  201. that.process = res.process
  202. if(that.process.isRetrospect==1){
  203. that.process.details.forEach(function(item) {
  204. if(item.valueType=='1'){
  205. item.value='OK'
  206. }
  207. });
  208. }
  209. }).catch((res) => {
  210. that.errorMsg = res.data.msg;
  211. })
  212. },
  213. productProcessReport(){
  214. let that = this,
  215. url = "wx/product/api/productProcessReport",
  216. params = {
  217. processId:that.processId,
  218. productModelId:that.productModelId
  219. }
  220. that.api.request(url, params,"get").then((res) => {
  221. console.log(res)
  222. that.processStats = res
  223. }).catch((res) => {
  224. })
  225. },
  226. initProcess(){
  227. this.qrCode=''
  228. this.errorMsg=''
  229. this.product=''
  230. this.productModel=''
  231. this.process=''
  232. this.images = []
  233. this.problemDesc=''
  234. this.isReworkRecord = false
  235. this.productProcessReport();
  236. },
  237. submit(){
  238. if(this.checkParam()){
  239. this.process.isStandards = (this.process.isRetrospect==0?-1:this.isReworkRecord?0:1)
  240. let urls = [];
  241. for(let i=0;i<this.images.length;i++){
  242. let url = this.images[i].url
  243. urls.push(url)
  244. }
  245. let that = this,
  246. url = "wx/product/api/processSubmit",
  247. params = {
  248. qrCode:that.qrCode,
  249. images:urls.join(","),
  250. productProcess:that.process,
  251. problemDesc:that.problemDesc,
  252. }
  253. that.api.request(url, params,'post','').then((res) => {
  254. that.api.toast("操作成功")
  255. that.initProcess();
  256. }).catch((res) => {
  257. })
  258. }
  259. },
  260. checkParam(){
  261. if(this.process.isPhotograph==1){
  262. this.api.toast("当前工序为拍照工序,请通过相机作业");
  263. return false;
  264. }
  265. if(this.process.isRetrospect==1){
  266. for(let item of this.process.details){
  267. if(!item.value){
  268. this.api.toast("请填写工序追溯内容");
  269. return false;
  270. }
  271. }
  272. let msg=[]
  273. for(let item of this.process.details){
  274. if(item.valueType=='2'){
  275. if(isNaN(parseFloat(item.value))){
  276. this.api.toast(item.processItemName+"的值非数字,请重新输入");
  277. return false;
  278. }
  279. if(parseFloat(item.maxValue) < parseFloat(item.value) || parseFloat(item.minValue) > parseFloat(item.value) ){
  280. msg.push(item.processItemName+"不达标,不在范围内")
  281. }
  282. }else{
  283. if(item.value != 'OK'){
  284. msg.push(item.processItemName+"不达标")
  285. }
  286. }
  287. }
  288. if(msg.length>0){
  289. this.isReworkRecord = true;
  290. if(this.images.length==0){
  291. uni.showModal({
  292. title: '提示',
  293. showCancel:false,
  294. content: msg.join(";\n")+";请上传图片发起维修"
  295. });
  296. return false;
  297. }
  298. }else{
  299. this.images = [];
  300. if(this.isReworkRecord == true){
  301. uni.showModal({
  302. title: '提示',
  303. showCancel:false,
  304. content: "工序追溯内容已达标,无需上传图片"
  305. });
  306. this.isReworkRecord = false
  307. return false;
  308. }
  309. }
  310. }
  311. return true;
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .page{
  318. .list{
  319. .tn-flex{
  320. padding-top: 30rpx;
  321. padding-bottom: 30rpx;
  322. view{
  323. }
  324. }
  325. }
  326. }
  327. .list-icon-text, .list-image-text {
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. }
  332. .list {
  333. &__left {
  334. display: flex;
  335. align-items: center;
  336. justify-content: flex-start;
  337. min-width: 140rpx;
  338. &__icon, &__image {
  339. margin-right: 18rpx;
  340. }
  341. }
  342. &__right {
  343. display: flex;
  344. align-items: center;
  345. justify-content: flex-end;
  346. flex-wrap: wrap;
  347. word-break: break-all;
  348. }
  349. }
  350. .tn-image-upload {
  351. display: flex;
  352. flex-direction: row;
  353. flex-wrap: wrap;
  354. align-items: center;
  355. &__item {
  356. /* #ifndef APP-NVUE */
  357. display: flex;
  358. /* #endif */
  359. align-items: center;
  360. justify-content: center;
  361. width: 200rpx;
  362. height: 200rpx;
  363. overflow: hidden;
  364. margin: 12rpx;
  365. margin-left: 0;
  366. background-color: $tn-font-holder-color;
  367. position: relative;
  368. border-radius: 10rpx;
  369. &-preview {
  370. border: 1rpx solid $tn-border-solid-color;
  371. &__image {
  372. display: block;
  373. width: 100%;
  374. height: 100%;
  375. border-radius: 10rpx;
  376. }
  377. }
  378. }
  379. }
  380. </style>