detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view>
  3. <!-- 单据明细 -->
  4. <view class="margin-top">
  5. <scroll-view :scroll-y="true" :show-scrollbar="true">
  6. <view class="scroll-list">
  7. <view class="list-item">
  8. <text class="text-gray item-title">工作中心</text>
  9. <text class="item-content">{{billDetail.workCenterGuid||''}}</text>
  10. </view>
  11. <view class="list-item">
  12. <text class="text-gray item-title">客户合同号</text>
  13. <text class="item-content">{{billDetail.khhth}}</text>
  14. </view>
  15. <view class="list-item">
  16. <text class="text-gray item-title">客户名称</text>
  17. <text class="item-content">{{billDetail.khmc}}</text>
  18. </view>
  19. <view class="list-item">
  20. <text class="text-gray item-title">加工指导书编号</text>
  21. <text class="item-content">{{billDetail.jgzdsbh}}</text>
  22. </view>
  23. <view class="list-item">
  24. <text class="text-gray item-title">销售物流号</text>
  25. <text class="item-content">{{billDetail.xswlh}}</text>
  26. </view>
  27. <view class="list-item">
  28. <text class="text-gray item-title">面料编码</text>
  29. <text class="item-content">{{billDetail.ynDyeFabCode}}</text>
  30. </view>
  31. <view class="list-item">
  32. <text class="text-gray item-title">合同交期</text>
  33. <text class="item-content">{{billDetail.htjq}}</text>
  34. </view>
  35. <view class="list-item">
  36. <text class="text-gray item-title">合同数量</text>
  37. <text class="item-content">{{billDetail.htsl}}</text>
  38. </view>
  39. <view class="list-item">
  40. <text class="text-gray item-title">计量单位</text>
  41. <text class="item-content">{{billDetail.jldw}}</text>
  42. </view>
  43. <view class="list-item">
  44. <text class="text-gray item-title">反馈初始结论</text>
  45. <text class="item-content">{{billDetail.fkcsjl||''}}</text>
  46. </view>
  47. <view class="list-item">
  48. <text class="text-gray item-title">反馈人</text>
  49. <text class="item-content">{{billDetail.fkr}}</text>
  50. </view>
  51. <view class="list-item">
  52. <text class="text-gray item-title">反馈时间</text>
  53. <text class="item-content">{{billDetail.fksj}}</text>
  54. </view>
  55. <view class="list-item">
  56. <text class="text-gray item-title">反馈次数</text>
  57. <text class="item-content">{{billDetail.fkcs}}</text>
  58. </view>
  59. <view class="list-item">
  60. <text class="text-gray item-title">反馈原因</text>
  61. <text class="item-content">{{billDetail.fkyy}}</text>
  62. </view>
  63. <view class="list-item">
  64. <text class="text-gray item-title">验装工厂处理结论</text>
  65. <text class="item-content">{{billDetail.yzgccljl||''}}</text>
  66. </view>
  67. <view class="list-item">
  68. <text class="text-gray item-title">验装工厂处理意见</text>
  69. <text class="item-content">{{billDetail.yzgcclyj||''}}</text>
  70. </view>
  71. <view class="list-item">
  72. <text class="text-gray item-title">验装工厂处理人</text>
  73. <text class="item-content">{{billDetail.yzgcclr||''}}</text>
  74. </view>
  75. <view class="list-item">
  76. <text class="text-gray item-title">验装工厂处理时间</text>
  77. <text class="item-content">{{billDetail.yzgcclsj||''}}</text>
  78. </view>
  79. <view class="list-item">
  80. <text class="text-gray item-title">验装工厂备注</text>
  81. <text class="item-content">{{billDetail.yzgcbz||''}}</text>
  82. </view>
  83. <view class="list-item">
  84. <text class="text-gray item-title">品管部最终处理结论</text>
  85. <text class="item-content">{{billDetail.pgbzzcljl||''}}</text>
  86. </view>
  87. <view class="list-item">
  88. <text class="text-gray item-title">品管部最终处理意见</text>
  89. <text class="item-content">{{billDetail.pgbzzclyj||''}}</text>
  90. </view>
  91. <view class="list-item">
  92. <text class="text-gray item-title">品管部最终处理人</text>
  93. <text class="item-content">{{billDetail.pgbzzclr||''}}</text>
  94. </view>
  95. <view class="list-item">
  96. <text class="text-gray item-title">品管部最终处理时间</text>
  97. <text class="item-content">{{billDetail.pgbzzclsj||''}}</text>
  98. </view>
  99. <view class="list-item">
  100. <text class="text-gray item-title">返工部门</text>
  101. <text class="item-content">{{billDetail.fgbm||''}}</text>
  102. </view>
  103. </view>
  104. </scroll-view>
  105. </view>
  106. <!-- 图片上传 -->
  107. <view class="margin-top">
  108. <view class="cu-bar bg-white">
  109. <view class="action">
  110. 图片上传
  111. </view>
  112. </view>
  113. <view class="cu-form-group">
  114. <view class="grid col-4 grid-square flex-sub">
  115. <view class="bg-img" v-for="(item,index) in imgList" @tap="ViewImage" :data-url="item.url">
  116. <image :src="item.url" mode="aspectFill"></image>
  117. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
  118. <text class='cuIcon-close'></text>
  119. </view>
  120. </view>
  121. <view class="solids" @tap="ChooseImage" v-if="imgList.length<9">
  122. <text class='cuIcon-cameraadd'></text>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 保存 -->
  128. <view class="padding margin-tb-sm text-center" v-show="isAllowEdit=='true'">
  129. <button class="cu-btn block round bg-blue lg" @click="upload">保存</button>
  130. </view>
  131. <mx-compress ref="mxCompress" />
  132. </view>
  133. </template>
  134. <script>
  135. //导入图片压缩组件
  136. import mxCompress from '../../components/mx-compress/mx-compress.vue';
  137. export default {
  138. components: {
  139. mxCompress //注册组件
  140. },
  141. data() {
  142. return {
  143. billDetail: {}, //单据明细
  144. isAllowEdit: '', //是否允许保存
  145. paramData: '', //单据列表页面获取数据参数
  146. imgList: [] //反馈图片列表
  147. }
  148. },
  149. onLoad(param) {
  150. //若加载页面时未提供参数值,则直接返回
  151. if (Object.keys(param).length == 0) return
  152. //给明细界面赋值、设置提交按钮是否可用以及记录单据列表页面是否查询全部单据
  153. this.billDetail = JSON.parse(decodeURIComponent(param.billData)) //数据中可能包括?、&这些特殊符号,需要通过decodeURIComponent解码
  154. this.isAllowEdit = param.isAllowEdit
  155. this.paramData = param.paramData
  156. //添加请求拦截器
  157. var vm = this
  158. uni.getStorage({
  159. key: 'token',
  160. success: function(res) {
  161. //请求拦截器
  162. uni.addInterceptor('request', {
  163. invoke(args) {
  164. args.header = {
  165. 'token': res.data
  166. }
  167. }
  168. })
  169. //获取已经上传的图片
  170. uni.request({
  171. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/getImgList',
  172. data: {
  173. orgFrameGuid: vm.billDetail.orgFrameGuid,
  174. jgzdsbh: vm.billDetail.jgzdsbh,
  175. xswlh: vm.billDetail.xswlh,
  176. fkcs: vm.billDetail.fkcs,
  177. },
  178. success: (res) => {
  179. if (res.data.code == 0) {
  180. //根据图片src链接显示已上传的图片
  181. vm.imgList = res.data.data;
  182. } else if (res.data.code == 101) { //未登录
  183. //清空token缓存
  184. uni.removeStorage({
  185. key: 'token',
  186. success: function(res) {
  187. //从redis缓存中未获取到token失败时跳转登录界面
  188. uni.navigateTo({
  189. url: '../login/login?isback=1'
  190. })
  191. },
  192. fail() {
  193. //从清空token缓存失败时提示
  194. uni.showToast({
  195. title: '登录已过期时,清空token缓存失败!',
  196. icon: 'none'
  197. })
  198. }
  199. });
  200. } else {
  201. uni.showToast({
  202. title: '获取反馈图片列表失败!原因是:' + res.data.msg,
  203. icon: 'none'
  204. })
  205. }
  206. },
  207. fail: (res) => {
  208. uni.showToast({
  209. title: '访问网络获取反馈图片列表失败!原因是:' + res.errMsg,
  210. icon: 'none'
  211. })
  212. }
  213. })
  214. },
  215. fail() {
  216. //从缓存中未获取到token失败时跳转登录界面
  217. uni.navigateTo({
  218. url: '../login/login?isback=1'
  219. })
  220. }
  221. });
  222. },
  223. onBackPress(e) {
  224. //返回上一页面,即单据列表页
  225. uni.navigateTo({
  226. url: '../billlist/billlist?paramData=' + this.paramData
  227. })
  228. //返回值为 true 时,才表示不执行默认的返回,自行处理此时的业务逻辑
  229. return true
  230. },
  231. methods: {
  232. ChooseImage() {
  233. uni.chooseImage({
  234. count: 9, //最大选择张数
  235. sizeType: ['original', 'compressed'], //缩略图及原图
  236. sourceType: ['camera', 'album'], //选择图片模式:相机、相册
  237. success: async (res) => {
  238. try {
  239. // 调用组件的compress方法开始压缩,返回值是压缩的结果,结果为数组,每一项是一个对象
  240. // {
  241. // file:'在H5中为File格式的图片数据,在小程序中为图片临时路径',
  242. // base64:'在H5和小程序中都是base64格式数据,只有当指定base64为true时才有'
  243. // }
  244. let result = await this.$refs.mxCompress.compress(res, {
  245. base64: true, // 是否也返回base64格式,默认false,既不返回base64格式图片数据,反之亦然
  246. maxLongSize: 1920, //最长尺寸
  247. quality: 0.8, // 压缩质量(0-1),默认为0.8,值越小压缩质量越大
  248. showLoading: true, // 是否显示loading提示,也可以传入一个字符串(相当于loading时的title),默认为true,
  249. mask: true // 当showLoading为true时,是否显示遮罩层,默认为true
  250. });
  251. //循环添加压缩后的图片
  252. for (let item of result) {
  253. //H5端:根据压缩后图片的base64格式数据来上传图片
  254. //#ifdef H5
  255. let imgSrc = item.base64;
  256. //#endif
  257. //小程序端:根据压缩后图片的临时路径来上传图片
  258. //#ifdef MP-WEIXIN
  259. let imgSrc = item.file;
  260. //#endif
  261. this.imgList.push({
  262. "url": imgSrc,
  263. "status": 0
  264. })
  265. }
  266. } catch (error) {
  267. uni.showToast({
  268. title: '图片压缩出现异常!原因是:' + error,
  269. icon: 'none'
  270. })
  271. }
  272. }
  273. });
  274. },
  275. ViewImage(e) {
  276. //获取当前单据上传的所有图片的url地址
  277. var imgUrls = []
  278. for (let item of this.imgList) {
  279. imgUrls.push(item.url)
  280. }
  281. //预览图片
  282. uni.previewImage({
  283. urls: imgUrls,
  284. current: e.currentTarget.dataset.url,
  285. });
  286. },
  287. DelImg(e) {
  288. //根据图片状态删除图片,若未上传至服务器,则直接删除,否则需删除服务器的图片
  289. var img = this.imgList[e.currentTarget.dataset.index]
  290. if (img.status == 0) {
  291. //界面删除图片
  292. this.imgList.splice(e.currentTarget.dataset.index, 1)
  293. } else {
  294. //图片已上传至服务器,询问用户是否确定删除
  295. uni.showModal({
  296. title: '提示',
  297. content: '此图片已上传至服务器,确定要删除这张面料图片吗?',
  298. cancelText: '保留',
  299. confirmText: '删除',
  300. success: result => {
  301. if (result.confirm) {
  302. //访问网络删除已上传的图片
  303. uni.request({
  304. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/deleteImg',
  305. data: {
  306. "imgId": img.id
  307. },
  308. success: (res) => {
  309. if (res.data.code == 0) {
  310. //数据库删除图片记录成功后,界面删除图片
  311. this.imgList.splice(e.currentTarget.dataset.index, 1);
  312. } else if (res.data.code == 101) { //未登录
  313. //清空token缓存
  314. uni.removeStorage({
  315. key: 'token',
  316. success: function(res) {
  317. //从redis缓存中未获取到token失败时跳转登录界面
  318. uni.navigateTo({
  319. url: '../login/login?isback=1'
  320. })
  321. },
  322. fail() {
  323. //从清空token缓存失败时提示
  324. uni.showToast({
  325. title: '登录已过期时,清空token缓存失败!',
  326. icon: 'none'
  327. })
  328. }
  329. });
  330. } else {
  331. uni.showToast({
  332. title: '删除反馈图片失败!原因是:' + res.data.msg,
  333. icon: 'none'
  334. })
  335. }
  336. },
  337. fail: (res) => {
  338. uni.showToast({
  339. title: '访问网络删除图片失败!原因是:' + res.errMsg,
  340. icon: 'none'
  341. })
  342. }
  343. })
  344. }
  345. }
  346. })
  347. }
  348. },
  349. upload() {
  350. //获取需要上传到服务器的图片列表
  351. var uploadImgs = this.imgList.filter(function(item) {
  352. return item.status == 0
  353. })
  354. //若没有需要上传的图片,则直接返回
  355. if (uploadImgs.length == 0) return
  356. //循环上传图片
  357. for (let file of uploadImgs) {
  358. //访问网络上传图片
  359. uni.uploadFile({
  360. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/uploadFile',
  361. name: "file",
  362. filePath: file.url,
  363. formData: {
  364. "orgFrameGuid": this.billDetail.orgFrameGuid,
  365. "jgzdsbh": this.billDetail.jgzdsbh,
  366. "xswlh": this.billDetail.xswlh,
  367. "fkcs": this.billDetail.fkcs
  368. },
  369. success: (res) => {
  370. let jsonData = JSON.parse(res.data);
  371. if (jsonData.code == 0) {
  372. //上传图片成功后,更新图片Id和状态
  373. file.id = jsonData.data.guid;
  374. file.status = 1;
  375. //提示保存成功
  376. uni.showToast({
  377. title: '保存成功',
  378. icon: 'success'
  379. })
  380. } else {
  381. //上传图片失败,弹框提示
  382. uni.showToast({
  383. title: '上传反馈图片失败!原因是:' + jsonData.msg,
  384. icon: 'none'
  385. })
  386. }
  387. },
  388. fail: (res) => {
  389. uni.showToast({
  390. title: '访问网络上传反馈图片失败!原因是:' + res.errMsg,
  391. icon: 'none'
  392. })
  393. }
  394. });
  395. }
  396. }
  397. }
  398. }
  399. </script>
  400. <style>
  401. .scroll-list {
  402. display: flex;
  403. flex-direction: column;
  404. flex-wrap: nowrap;
  405. justify-content: space-between;
  406. align-items: stretch;
  407. height: 750rpx;
  408. }
  409. .list-item {
  410. display: flex;
  411. flex-direction: row;
  412. flex-wrap: nowrap;
  413. justify-content: flex-start;
  414. align-items: center;
  415. min-height: max-content;
  416. background-color: #FFFFFF;
  417. font-size: 30upx;
  418. line-height: 80upx;
  419. }
  420. .list-item+.list-item {
  421. border-top: 1upx solid #8799a3;
  422. }
  423. .item-title {
  424. padding-inline-start: 3%;
  425. width: 40%;
  426. text-align: start;
  427. }
  428. .item-content {
  429. text-align: justify;
  430. word-break: break-all;
  431. width: 60%;
  432. line-height: 50upx;
  433. }
  434. </style>