index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="home" style="padding-bottom: 150upx">
  3. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  4. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true">
  5. <block slot="content">抽样列表</block>
  6. </cu-custom>
  7. <view class="padding">
  8. <!-- @tap="toSampleDetail(item.id,item.sampleStatus)"-->
  9. <view class="cu-list menu bg-white" v-for="(item, index) in sampleSheetDataList">
  10. <view class="cu-item solids-bottom">
  11. <view class="title">
  12. <text class="cuIcon-titles text-green"></text>
  13. <text class="text-black text-bold text-lg">{{ index + 1 }}.{{ item.samplingNumber }}</text>
  14. </view>
  15. <view class="action">
  16. <view class="text-blue" v-show="item.sampleStatus === 'SAMPLE_FILLED'">已填报</view>
  17. <view class="text-gray" v-show="item.sampleStatus === 'SAMPLE_REPORT'">已上报</view>
  18. <view class="text-red" v-show="item.sampleStatus === 'SAMPLE_WAIT_FILL'">待填报</view>
  19. </view>
  20. </view>
  21. <view class="cu-item">
  22. <view class="content detail padding-bottom">
  23. <!-- <image src="/static/logo.png" class="png" mode="aspectFit"></image> -->
  24. <div class="text-gray" v-if="item.samplingPeopleFirst">抽样人员1:{{ item.samplingPeopleFirst }}</div>
  25. <div class="text-gray" v-if="item.samplingPeopleSecond">抽样人员2:{{ item.samplingPeopleSecond }}</div>
  26. <div class="text-gray">创建时间:{{ item.createTime }}</div>
  27. <div class="text-gray">更新时间:{{ item.updateTime }}</div>
  28. <!-- <div class="text-gray">状态:{{ setSampleStatus(item.sampleStatus) }}</div>-->
  29. </view>
  30. </view>
  31. <view class="tools padding-sm">
  32. <view @tap="deleteAhSampleSheet(item.id)">
  33. <view class="btn-item text-black text-bold">
  34. <text class="cuIcon-deletefill lg"></text>
  35. <text class="text-sm">删除</text>
  36. </view>
  37. </view>
  38. <view style="display: flex;justify-content: space-between;gap:30upx">
  39. <view class="tool margin-left-sm" @tap="exportFile(item.id)" v-if="item.sampleStatus === 'SAMPLE_FILLED'">
  40. <view class="cu-tag bg-green light text-df text-bold">
  41. <text class="cuIcon-newshotfill lg"></text>
  42. 导出抽样单
  43. </view>
  44. </view>
  45. <view class="tool" @tap="toSampleDetail(item.id)">
  46. <view class="cu-tag bg-blue light text-df text-bold">
  47. 去填报
  48. <text class="cuIcon-right lg"></text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="reviewBtn" @tap="addSheet" v-if="showUpBtn">
  56. <view class="subBtn bg-green">
  57. 添加
  58. </view>
  59. </view>
  60. <view class="padding flex flex-direction padding-bottom-xl fixedFootBtn bg-white padding-top-xs" v-if="sampleSheetDataList.length >= 1 && showUpBtn">
  61. <button class="cu-btn bg-green lg margin-top-sm shadow-blur" type="" @tap="upSheet">
  62. 上报
  63. </button>
  64. </view>
  65. <view class="cu-modal" :class="modalName==='addSample'?'show':''">
  66. <view class="cu-dialog">
  67. <view class="cu-bar bg-white justify-end">
  68. <view class="content" style="width: 100%">添加抽样单</view>
  69. <view class="action" @tap="hideModal">
  70. <text class="cuIcon-close text-red"></text>
  71. </view>
  72. </view>
  73. <view class="padding-lr-lg bg-white padding-bottom">
  74. <view class="cu-list menu">
  75. <view class="cu-form-group ">
  76. <view class="title">抽样人员1</view>
  77. <input name="input" v-model="options.samplingPeopleFirst" placeholder="请输入抽样人员1">
  78. </view>
  79. <view class="cu-form-group ">
  80. <view class="title">抽样人员2</view>
  81. <input name="input" v-model="options.samplingPeopleSecond" placeholder="请输入抽样人员2">
  82. </view>
  83. </view>
  84. <view class="padding flex flex-direction">
  85. <button class="cu-btn bg-blue lg" @tap="submitSampleSheet">提交</button>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. _sampleList
  95. } from "./sample-list-model.js";
  96. import {
  97. _taskList
  98. } from "../task-list/task-list-model.js";
  99. import {_sampleSheetAdd} from '../sample-sheet-add/sample-sheet-add-model.js'
  100. export default {
  101. data() {
  102. return {
  103. sampleSheetDataList: [],
  104. sampleStatus: [],
  105. addBackground: "background-color:#c0c0c0",
  106. uploadBackground: "background-color:#c0c0c0",
  107. options: {},
  108. modalName:null,
  109. showUpBtn:true
  110. };
  111. },
  112. onLoad(options) {
  113. if (options.status === "SAMPLE_SUCCESS" || options.status === "CHECK_PROCESS" || options.status === "SAMPLE_CHECK_SUCCESS") {
  114. this.addBackground = "background-color: #c0c0c0";
  115. this.uploadBackground = "background-color: #c0c0c0";
  116. this.showUpBtn = false;
  117. } else {
  118. this.addBackground = "background-color: #00B525";
  119. this.uploadBackground = "background-color: #0081ff";
  120. }
  121. this.options = options;
  122. this.getSampleStatus();
  123. },
  124. onShow() {
  125. this.getAhSampleSheetList(this.options);
  126. },
  127. methods: {
  128. //添加
  129. addSheet() {
  130. if (this.options.status === "SAMPLE_SUCCESS" || this.options.status === "CHECK_PROCESS" || this.options.status === "SAMPLE_CHECK_SUCCESS") {
  131. console.log("不可添加");
  132. } else {
  133. console.log("调用添加弹窗");
  134. console.log(this.options);
  135. this.modalName = "addSample"
  136. /*uni.navigateTo({
  137. url: "/pages/sample-sheet-add/index?checkId=" + this.options.checkId + "&sampleId=" + this.options.sampleId
  138. + "&taskId=" + this.options.taskId + "&zoneId=" + this.options.zoneId
  139. });*/
  140. }
  141. },
  142. //新建抽样单
  143. submitSampleSheet(){
  144. if(!this.options.samplingPeopleFirst && !this.options.samplingPeopleSecond){
  145. this.$msg("请填写抽样人员");
  146. return false;
  147. }
  148. _sampleSheetAdd.createAhSampleSheet(this.options, res=>{
  149. console.log(res.data)
  150. const {data:{code,message}} = res;
  151. if(code===200){
  152. this.$success("添加成功");
  153. delete this.options.samplingPeopleFirst;
  154. delete this.options.samplingPeopleSecond;
  155. this.getAhSampleSheetList(this.options);
  156. this.modalName = null;
  157. }else{
  158. this.$msg(message);
  159. }
  160. })
  161. },
  162. /**
  163. * 上报抽样单
  164. */
  165. upSheet() {
  166. if (this.options.status === "SAMPLE_SUCCESS" || this.options.status === "CHECK_PROCESS" || this.options.status === "SAMPLE_CHECK_SUCCESS") {
  167. console.log("不可上报");
  168. this.$msg("不可重复上报");
  169. } else {
  170. _sampleList.upBatchSampleSheet(this.options,res=>{
  171. console.log(res);
  172. const {code,message} = res;
  173. if(code === 200){
  174. this.$success("上报成功");
  175. this.getAhSampleSheetList(this.options);
  176. this.showUpBtn = false;
  177. }else{
  178. this.$msg(message);
  179. }
  180. })
  181. }
  182. },
  183. /**
  184. * 删除抽样单
  185. */
  186. deleteAhSampleSheet(id){
  187. uni.showModal({
  188. title: "提示",
  189. content: "确定要删除当前样本么",
  190. cancelText: "取消",
  191. confirmText: "确认",
  192. success: res => {
  193. if (res.confirm) {
  194. _sampleList.deleteAhSampleSheet(id, res => {
  195. const {code,message} = res;
  196. if(code === 200){
  197. this.$success("删除成功");
  198. this.getAhSampleSheetList(this.options);
  199. }else{
  200. this.$msg(message);
  201. }
  202. });
  203. }
  204. }
  205. });
  206. },
  207. toSampleDetail(id, status) {
  208. uni.navigateTo({
  209. url: "/pages/sample-detail/index?id=" + id + "&status=" + status
  210. });
  211. },
  212. exportFile(id) {
  213. _sampleList.exportSampleSheetPdf(id,res=>{
  214. const {code,message} = res;
  215. if(code === 200){
  216. uni.downloadFile({
  217. url: res.data, //仅为示例,并非真实的资源
  218. success:res=> {
  219. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  220. if (res.statusCode === 200) {
  221. /*wx.playVoice({
  222. filePath: res.tempFilePath
  223. })*/
  224. this.$msg(JSON.stringify(res),100000);
  225. const filePath = res.tempFilePath
  226. uni.openDocument({
  227. filePath: filePath,
  228. showMenu:true,
  229. fileType:"pdf",
  230. success: ()=>{
  231. console.log('打开文档成功')
  232. },
  233. fail:(err)=>{
  234. this.$msg("文件查看失败");
  235. console.log("文件查看失败,err:",err)
  236. }
  237. })
  238. }
  239. },
  240. fail:(err)=>{
  241. this.$msg("文件下载失败");
  242. console.log("文件下载失败,err:",err)
  243. }
  244. })
  245. }else{
  246. this.$msg("文件下载失败");
  247. console.log("文件生成失败,message:",message)
  248. }
  249. })
  250. },
  251. getAhSampleSheetList(item) {
  252. _sampleList.getAhSampleSheet(item, res => {
  253. this.sampleSheetDataList = res.data.data.records;
  254. });
  255. },
  256. getSampleStatus() {
  257. _taskList.getDictionary("SAMPLE_SHEET_STATUS", res => {
  258. this.sampleStatus = res.data.data;
  259. });
  260. },
  261. setSampleStatus(value) {
  262. let sampleStatus = this.sampleStatus;
  263. for (let i = 0; i < sampleStatus.length; i++) {
  264. if (sampleStatus[i].itemValue === value) {
  265. return sampleStatus[i].itemKey;
  266. }
  267. }
  268. },
  269. hideModal(){
  270. this.modalName = "";
  271. },
  272. }
  273. };
  274. </script>
  275. <style scoped>
  276. .detail view {
  277. height: 1.8em;
  278. line-height: 1.8em !important;
  279. border: none;
  280. color: gray;
  281. }
  282. .tools {
  283. display: flex;
  284. align-items: center;
  285. justify-content: space-between;
  286. padding: 20upx;
  287. }
  288. .btn-item{
  289. display: flex;
  290. flex-direction: column;
  291. justify-content: center;
  292. align-items: center;
  293. }
  294. /*.cu-tag{
  295. !*padding: 20upx;*!
  296. border-radius: 10upx 10upx;
  297. }*/
  298. </style>