index.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <template>
  2. <view class="page">
  3. <view class="DrawerPage" :class="modalName=='DrawerModalL'?'show':''">
  4. <scroll-view scroll-y style="height: 100vh;z-index: 3">
  5. <cu-custom class="home-custom" bgColor=".bg-sancolor"
  6. bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png"
  7. :isBack="true">
  8. <block slot="content">填报抽样单</block>
  9. </cu-custom>
  10. <view :style="'z-index:2;position: sticky;top:calc('+CustomBar+'px - 80rpx)' ">
  11. <view class="cu-list menu">
  12. <view class="cu-item" style="min-height: 80rpx">
  13. <view class="content">
  14. <text class="cuIcon-formfill text-black lg"></text>
  15. <text class="text-black">编号:{{ sampleDetailInfo.samplingNumber }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="bg-white nav solid-bottom">
  20. <view class="flex text-center">
  21. <view class="cu-item flex-sub" :class="pageIndex === 0?'text-blue cur':''"
  22. @tap="pageIndex = 0">
  23. 抽样单信息
  24. </view>
  25. <view class="cu-item flex-sub" :class="pageIndex === 1?'text-blue cur':''"
  26. @tap="pageIndex = 1">
  27. 抽样填报
  28. </view>
  29. <view class="cu-item flex-sub" :class="pageIndex === 2?'text-blue cur':''"
  30. @tap="pageIndex = 2">
  31. 现场照片
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view style="padding-bottom: 180rpx;">
  37. <!--基本信息-->
  38. <view v-show="pageIndex === 0">
  39. <view class="cu-list menu">
  40. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  41. <view class="action">
  42. <text class="cuIcon-titles text-green"></text>
  43. <text>被抽查单位信息</text>
  44. </view>
  45. </view>
  46. <form>
  47. <view class="cu-form-group">
  48. <view class="title">单位名称</view>
  49. <view>
  50. {{ sampleDetailInfo.bySampleUnitName}}
  51. </view>
  52. <!-- <input :disabled="input_diabled" placeholder="请输入单位名称" name="input"
  53. v-model="sampleDetailInfo.bySampleUnitName"></input>-->
  54. </view>
  55. <view class="cu-form-group ">
  56. <view class="title">单位地址</view>
  57. <input placeholder="请输入单位地址"
  58. name="input"
  59. v-model="sampleDetailInfo.bySampleAddress" disabled></input>
  60. </view>
  61. <view class="cu-form-group ">
  62. <view class="title">联系人</view>
  63. <input placeholder="请输入联系人" name="input"
  64. v-model="sampleDetailInfo.bySampleContactName" disabled></input>
  65. </view>
  66. <view class="cu-form-group ">
  67. <view class="title">电话</view>
  68. <input placeholder="请输入电话" name="input"
  69. v-model="sampleDetailInfo.bySampleContactPhone" disabled></input>
  70. </view>
  71. </form>
  72. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  73. <view class="action">
  74. <text class="cuIcon-titles text-green"></text>
  75. <text>抽样单位信息</text>
  76. </view>
  77. </view>
  78. <form>
  79. <view class="cu-form-group">
  80. <view class="title">单位名称</view>
  81. <input placeholder="请输入单位名称" name="input"
  82. v-model="sampleDetailInfo.sampleUnitName" disabled></input>
  83. </view>
  84. <view class="cu-form-group ">
  85. <view class="title">单位地址</view>
  86. <input placeholder="请输入单位地址" name="input"
  87. v-model="sampleDetailInfo.sampleAddress" disabled></input>
  88. </view>
  89. <view class="cu-form-group ">
  90. <view class="title">联系人</view>
  91. <input placeholder="请输入联系人" name="input"
  92. v-model="sampleDetailInfo.sampleContactName" disabled></input>
  93. </view>
  94. <view class="cu-form-group">
  95. <view class="title">电话</view>
  96. <input placeholder="请输入电话" name="input"
  97. v-model="sampleDetailInfo.sampleContactPhone" disabled></input>
  98. </view>
  99. <view class="cu-form-group align-start">
  100. <view class="title">备注</view>
  101. <textarea placeholder="请输入抽样备注" name="input"
  102. v-model="sampleDetailInfo.samplingMask" :disabled="input_diabled"></textarea>
  103. </view>
  104. </form>
  105. <!-- <view class="padding flex flex-direction">
  106. <button class="cu-btn bg-green lg" @tap="toSampleInfoList(sampleDetailInfo.id)">管理样品
  107. </button>
  108. </view>-->
  109. <!-- <view class="padding flex flex-direction">
  110. &lt;!&ndash; <button class="cu-btn bg-green lg shadow-blur" @tap="saveSampleInfoList">保存</button>&ndash;&gt;
  111. <button class="cu-btn bg-green lg shadow-blur" @tap="pageIndex = 1">填报抽样信息</button>
  112. </view>-->
  113. </view>
  114. </view>
  115. <view v-show="pageIndex === 1">
  116. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  117. <view class="action">
  118. <text class="cuIcon-titles text-green"></text>
  119. <text>抽样基地信息</text>
  120. </view>
  121. </view>
  122. <form>
  123. <view class="cu-form-group">
  124. <view class="title">基地名称</view>
  125. <picker @tap="showBaseSelect" @change="baseSelectChange" :value="baseSelectIndex" :range="baseSelectList" :disabled="disabledBaseSelect">
  126. <view class="picker">
  127. {{ baseSelectList[baseSelectIndex] || "请选择抽样地点" }}
  128. </view>
  129. </picker>
  130. </view>
  131. <view class="cu-form-group">
  132. <view class="title">抽样地点</view>
  133. <input placeholder="请选择抽样地点" name="input"
  134. v-model="sampleDetailInfo.samplingAddress" disabled></input>
  135. </view>
  136. </form>
  137. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  138. <view class="action">
  139. <text class="cuIcon-titles text-green"></text>
  140. <text>抽样信息</text>
  141. </view>
  142. <view class="action">
  143. <button class="cu-btn bg-green" type="" @tap="addSampleProduct" v-if="!input_diabled"> 增加样品</button>
  144. </view>
  145. </view>
  146. <view class="padding-sm">
  147. <view class="cu-list menu bg-white"
  148. v-for="(item, index) in ahSampleDetailList" :key="index">
  149. <view class="cu-item">
  150. <view class="title text-black text-bold text-lg">
  151. <text class="cuIcon-titles text-green"></text>
  152. {{ index + 1 }}.{{ item.name }}
  153. </view>
  154. <view class="action">
  155. {{ item.samplingDate }}
  156. </view>
  157. </view>
  158. <view class="content detail padding-sm solid-bottom">
  159. <div class="text-gray">样品来源:{{ item.source }}</div>
  160. <div class="text-gray">抽样数量:{{ item.samplingNumber }}{{ item.samplingType }}</div>
  161. <div class="text-gray">抽样基数:{{ item.samplingBase }}{{ item.samplingType }}</div>
  162. <div class="text-gray">生产日期:{{ item.manufactureDate }}</div>
  163. </view>
  164. <view class="tools padding-sm" v-if="!input_diabled">
  165. <view @tap="delSampleDetail(item.id)">
  166. <view class="cu-tag radius line-red padding-lr-sl">
  167. <text class="cuIcon-deletefill text-lg padding-right-xs"></text>
  168. 删除
  169. </view>
  170. </view>
  171. <view class="tool"
  172. @tap="editSampleDetail(index)">
  173. <view class="cu-tag bg-blue light text-df text-bold">
  174. <text class="cuIcon-edit text-lg padding-right-xs"></text>
  175. 修改
  176. </view>
  177. </view>
  178. </view>
  179. </view>
  180. <view class="radius shadow-warp bg-white text-lg" v-if="ahSampleDetailList.length === 0">
  181. <view class="cu-list menu-avatar">
  182. <view class="cu-item">
  183. <view class="content">
  184. <view class="text-sm text-center" style="justify-content: center;">
  185. <text class="text-cut text-lg">
  186. <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
  187. 未查询到样本数据
  188. </text>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. <view v-show="pageIndex === 2">
  197. <view class="cu-list menu">
  198. <view class="cu-form-group margin-top-sm">
  199. <view class="title">同行抽检员</view>
  200. <picker :disabled="true" @tap="showSecondCyUserChoose">
  201. <view class="picker">
  202. {{ sampleDetailInfo.samplingPeopleSecond || '请选择' }}
  203. </view>
  204. </picker>
  205. </view>
  206. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  207. <view class="action">
  208. <text class="cuIcon-titles text-green"></text>
  209. <text>抽样单照片</text>
  210. </view>
  211. </view>
  212. <view class="cu-form-group">
  213. <view class="grid col-3 grid-square flex-sub">
  214. <view class="bg-img" @tap="ViewImage(photo.sampleSheetPhoto)" v-if="photo.sampleSheetPhoto">
  215. <image :src='photo.sampleSheetPhoto' mode='aspectFill'></image>
  216. <view class="cu-tag bg-red" @tap="DelImg('sampleSheetPhoto')">
  217. <text class="cuIcon-close"></text>
  218. </view>
  219. </view>
  220. <view class="solids" @tap="ChooseImage('sampleSheetPhoto')" v-if="!photo.sampleSheetPhoto">
  221. <text class="cuIcon-cameraadd"></text>
  222. </view>
  223. </view>
  224. </view>
  225. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  226. <view class="action">
  227. <text class="cuIcon-titles text-green"></text>
  228. <text>封样照片</text>
  229. </view>
  230. </view>
  231. <view class="cu-form-group">
  232. <view class="grid col-3 grid-square flex-sub">
  233. <view class="bg-img" @tap="ViewImage(photo.sealingPhoto)" v-if="photo.sealingPhoto">
  234. <image :src='photo.sealingPhoto' mode='aspectFill'></image>
  235. <view class="cu-tag bg-red" @tap="DelImg('sealingPhoto')">
  236. <text class="cuIcon-close"></text>
  237. </view>
  238. </view>
  239. <view class="solids" @tap="ChooseImage('sealingPhoto')" v-if="!photo.sealingPhoto">
  240. <text class="cuIcon-cameraadd"></text>
  241. </view>
  242. </view>
  243. </view>
  244. <view class="cu-bar bg-white margin-top-sm solid-bottom">
  245. <view class="action">
  246. <text class="cuIcon-titles text-green"></text>
  247. <text>抽样人员合影照片</text>
  248. </view>
  249. </view>
  250. <view class="cu-form-group">
  251. <view class="grid col-3 grid-square flex-sub">
  252. <view class="bg-img" @tap="ViewImage(photo.groupPhoto)" v-if="photo.groupPhoto">
  253. <image :src='photo.groupPhoto' mode='aspectFill'></image>
  254. <view class="cu-tag bg-red" @tap="DelImg('groupPhoto')">
  255. <text class="cuIcon-close"></text>
  256. </view>
  257. </view>
  258. <view class="solids" @tap="ChooseImage('groupPhoto')" v-if="!photo.groupPhoto">
  259. <text class="cuIcon-cameraadd"></text>
  260. </view>
  261. </view>
  262. </view>
  263. </view>
  264. </view>
  265. <view class="padding flex flex-direction padding-bottom-xl fixedFootBtn bg-white padding-top-xs" v-if="!sampleDetailInfo.filledPeopleId">
  266. <button class="cu-btn bg-blue lg margin-top-sm shadow-blur" type="" v-if="!input_diabled" :disabled="!disabledBaseSelect"
  267. @tap="publishSampleSheet">上报抽样单
  268. </button>
  269. </view>
  270. </view>
  271. </scroll-view>
  272. </view>
  273. <view class="cu-modal bottom-modal" :class="modalName==='addSimpleInfo'?'show':''" @tap="hideModal">
  274. <view class="cu-dialog btDialog padding-bottom-lg" @tap.stop.prevent>
  275. <view class="cu-bar bg-white padding-lr solid-bottom">
  276. <view></view>
  277. <view class="action text-orange" @tap="hideModal">关闭</view>
  278. </view>
  279. <!-- <view class="box">
  280. <view class="cu-bar justify-center bg-white">
  281. <view class="action sub-title">
  282. <text class="text-xl text-bold text-blue">添加样品</text>
  283. <text class="text-ABC text-blue">sample</text>
  284. &lt;!&ndash; last-child选择器&ndash;&gt;
  285. </view>
  286. </view>
  287. </view>-->
  288. <view class="padding-lr bg-white">
  289. <view class="cu-form-group">
  290. <view class="title">样品名称</view>
  291. <picker @change="productSelectChange" data-target="name" :value="ahSampleDetail.name"
  292. :range="productList">
  293. <view class="picker">
  294. {{ ahSampleDetail.name || "请选择样品名称" }}
  295. </view>
  296. </picker>
  297. </view>
  298. <view class="cu-form-group">
  299. <view class="title">样品来源</view>
  300. <radio-group class="block" @change="sourceTypeChange">
  301. <view>
  302. <checkbox class="radio" id="zc" :value="1" :checked="''+sourceType === '1'"></checkbox>
  303. <label class="title margin-left-sm" for="zc">自产</label>
  304. <checkbox class="radio" id="qt" :value="2" :checked="''+sourceType === '2'"></checkbox>
  305. <label class="title margin-left-sm" for="qt">其他</label>
  306. </view>
  307. </radio-group>
  308. </view>
  309. <view class="cu-form-group" v-show="''+sourceType === '2'">
  310. <view class="title">详细地址</view>
  311. <input placeholder="请输入详细地址" type="text" v-model="ahSampleDetail.source">
  312. </view>
  313. <view class="cu-form-group">
  314. <view class="title">抽样日期</view>
  315. <picker mode="date" :value="ahSampleDetail.samplingDate" data-target="samplingDate"
  316. start="2000-01-01" :end="nowDate" @change="dateChange">
  317. <view class="picker">
  318. {{ ahSampleDetail.samplingDate || "请选择抽样日期" }}
  319. </view>
  320. </picker>
  321. </view>
  322. <view class="cu-form-group">
  323. <view class="title">抽样数量</view>
  324. <input placeholder="请输入抽样数量" type="digit" v-model="ahSampleDetail.samplingNumber">
  325. </view>
  326. <view class="cu-form-group">
  327. <view class="title">抽样基数</view>
  328. <input placeholder="请输入抽样基数" type="digit" v-model="ahSampleDetail.samplingBase">
  329. </view>
  330. <view class="cu-form-group">
  331. <view class="title">样品单位</view>
  332. <picker @change="unitChange" data-target="samplingType" :value="ahSampleDetail.samplingType"
  333. :range="dictTypeList">
  334. <view class="picker">
  335. {{ ahSampleDetail.samplingType || "请选择样品单位" }}
  336. </view>
  337. </picker>
  338. </view>
  339. <view class="cu-form-group solid-bottom">
  340. <view class="title">生产日期</view>
  341. <picker mode="date" :value="ahSampleDetail.manufactureDate" data-target="manufactureDate"
  342. start="2000-01-01" :end="nowDate" @change="dateChange">
  343. <view class="picker">
  344. {{ ahSampleDetail.manufactureDate || "请选择生产日期" }}
  345. </view>
  346. </picker>
  347. </view>
  348. <view class="padding flex flex-direction">
  349. <button class="cu-btn bg-blue lg margin-tb-sm shadow-blur text-lg"
  350. @click="createAhSampleDetail">保存
  351. </button>
  352. <!-- <button class="cu-btn line-red lg shadow-blur text-lg" @tap="hideModal">取消</button>-->
  353. </view>
  354. </view>
  355. </view>
  356. </view>
  357. <view class="cu-modal bottom-modal" :class="modalName==='userListModal'?'show':''">
  358. <view class="cu-dialog" @tap.stop.prevent>
  359. <view class="cu-bar bg-white">
  360. <view class="action text-blue" @tap="hideModal">取消</view>
  361. <view class="content text-bold">选择抽样人员</view>
  362. </view>
  363. <view class="bg-white">
  364. <view class="cu-bar search bg-white">
  365. <view class="search-form radius text-left">
  366. <text class="cuIcon-search"></text>
  367. <input type="text" placeholder="输入样品名称搜索" confirm-type="search"
  368. v-model="queryUserName" />
  369. <text class="cuIcon cuIcon-close endClass text-xxl text-bold" @tap="resetQymcQuery"
  370. v-show="queryUserName !== ''"></text>
  371. </view>
  372. <view class="action"><!-- 全部的按钮 -->
  373. <button class="cu-btn bg-green shadow-blur round" @tap="searchProduct">搜索</button>
  374. </view>
  375. </view>
  376. <scroll-view scroll-y class="productScroll padding" @scrolltolower="getCyUserList">
  377. <radio-group @change="cyUserChange" style="width: 100%">
  378. <view class="flex flex-wrap text-left">
  379. <view class="basis-df padding-xs text-left" v-for="(item,index) in cyUserList"
  380. :key="index">
  381. <checkbox :value="item.id" class="radio" :id="'productName'+index"
  382. :checked="sampleDetailInfo.samplingPeopleSecondId === item.id"></checkbox>
  383. <label :for="'productName'+index">{{ item.name }}</label>
  384. </view>
  385. </view>
  386. </radio-group>
  387. </scroll-view>
  388. </view>
  389. </view>
  390. </view>
  391. </view>
  392. </template>
  393. <script>
  394. import { _sampleDetail } from "./sample-detail-model.js";
  395. export default {
  396. data() {
  397. return {
  398. CustomBar: this.CustomBar,
  399. pageIndex: 0,
  400. photo: {
  401. sampleSheetPhoto: null,
  402. sealingPhoto: null,
  403. groupPhoto: null,
  404. },
  405. basicsList: [{
  406. icon: "usefullfill",
  407. name: "开始"
  408. }, {
  409. icon: "formfill",
  410. name: "检查信息"
  411. }],
  412. sampleDetailInfo: {},
  413. regionArray: [],
  414. regionIndex: [],
  415. xzqObjList: [],
  416. queryXzq: "请选择",
  417. queryXzqdm: "",
  418. input_diabled: false,
  419. modalName: null,
  420. pageNum: 1,
  421. pageSize: 100,
  422. pageTotal: 1,
  423. cyUserList:[],
  424. enterprisesName: null,
  425. qyList: [],
  426. ahSampleDetail: {},
  427. nowDate: null,
  428. dictTypeList: [],
  429. baseList: [], //基地列表
  430. baseSelectList: [],
  431. baseSelectIndex: 0,
  432. productList: [],
  433. serviceProductList: [],
  434. productIndex: 0,
  435. sourceType: null, //样品来源类型
  436. ahSampleDetailList: [],
  437. userinfo:{},
  438. id:null,
  439. queryUserName:""
  440. };
  441. },
  442. onLoad(options) {
  443. this.id = options.id;
  444. this.userinfo = uni.getStorageSync("userInfo");
  445. const now = new Date();
  446. this.nowDate = now.getFullYear() + "-" + ("" + (now.getMonth())).padStart(2, "0") + "-" + ("" + now.getDate()).padStart(2, "0");
  447. this.getDictTypeList();
  448. this.getCyUserList();
  449. this.getSampleInfoDetail(this.id);
  450. },
  451. computed:{
  452. disabledBaseSelect(){
  453. return this.ahSampleDetailList.length >= 1
  454. }
  455. },
  456. methods: {
  457. ChooseImage(name) {
  458. uni.chooseImage({
  459. count: 1, //默认9
  460. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  461. sourceType: ['album'], //从相册选择
  462. success: (res) => {
  463. uni.showLoading({
  464. title: '图片上传中'
  465. })
  466. _sampleDetail.uploadPhoto(res.tempFilePaths[0], res => {
  467. const {code, data, message} = JSON.parse(res);
  468. uni.hideLoading()
  469. if (code === 200) {
  470. this.$set(this.photo,name,data);
  471. } else {
  472. this.$msg(message);
  473. }
  474. console.log(this.photo);
  475. })
  476. }
  477. });
  478. },
  479. ViewImage(url) {
  480. uni.previewImage({
  481. urls: [url],
  482. current: url
  483. });
  484. },
  485. DelImg(name) {
  486. uni.showModal({
  487. title: '图片删除',
  488. content: '确定要删除图片吗?',
  489. cancelText: '取消',
  490. confirmText: '确认',
  491. success: res => {
  492. if (res.confirm) {
  493. this.photo[name] = null
  494. }
  495. }
  496. })
  497. },
  498. showBaseSelect(){
  499. if(this.ahSampleDetailList.length >= 1){
  500. this.$msg("已上传抽样样品,基地信息不可修改")
  501. return
  502. }
  503. },
  504. addSampleProduct(){
  505. if(!this.sampleDetailInfo.baseNumber){
  506. this.$msg("请选择检查基地");
  507. } else {
  508. if(this.ahSampleDetailList.length >= 3){
  509. this.$msg("一个抽样单最多仅可添加3个样本");
  510. return
  511. }
  512. this.modalName = 'addSimpleInfo'
  513. }
  514. },
  515. getSubXzqList(xzqdm) {
  516. return new Promise(resolve => {
  517. _sampleDetail.getSubXzqList(xzqdm, res => {
  518. resolve(res);
  519. });
  520. });
  521. },
  522. /**
  523. * 获取单位选项
  524. */
  525. getDictTypeList() {
  526. _sampleDetail.getDictTypeList(res => {
  527. const { code, data: { records } } = res;
  528. if (code === 200) {
  529. this.dictTypeList = records.map(v => v.type);
  530. } else {
  531. this.$msg("单位获取失败");
  532. }
  533. });
  534. },
  535. /**
  536. * 样品单位改变
  537. * @param e
  538. */
  539. unitChange(e) {
  540. this.setDateHandle(this.ahSampleDetail, "samplingType", this.dictTypeList[e.detail.value]);
  541. },
  542. /**
  543. * 样品名称选择
  544. * @param e
  545. */
  546. productSelectChange(e) {
  547. // this.ahSampleDetail.name = ;
  548. const index = e.detail.value;
  549. if(index >= 1){
  550. this.setDateHandle(this.ahSampleDetail, "name", this.serviceProductList[index].productName);
  551. }else{
  552. this.setDateHandle(this.ahSampleDetail, "name", null);
  553. }
  554. },
  555. /**
  556. * 日期选择回调
  557. * @constructor
  558. */
  559. dateChange(e) {
  560. const { target } = e.currentTarget.dataset;
  561. const value = e.detail.value;
  562. if (this.ahSampleDetail.hasOwnProperty(target)) {
  563. this.ahSampleDetail[target] = value;
  564. } else {
  565. this.$set(this.ahSampleDetail, target, value);
  566. }
  567. },
  568. /**
  569. * 样品来源类型选择
  570. * @param e
  571. */
  572. sourceTypeChange(e) {
  573. this.sourceType = e.detail.value;
  574. },
  575. /**
  576. * 基地选择回调
  577. */
  578. baseSelectChange(e) {
  579. const value = e.detail.value;
  580. if ("" + value !== "0") {
  581. this.baseSelectIndex = value;
  582. const base = this.baseList[value];
  583. this.sampleDetailInfo.samplingAddress = base.city + base.county + base.towns + base.village;
  584. this.sampleDetailInfo.baseNumber = base.baseNumber;
  585. this.getProductBatchList(base);
  586. } else {
  587. this.$msg("请选择地址");
  588. this.sampleDetailInfo.samplingAddress = "";
  589. }
  590. },
  591. getSampleInfoDetail(id) {
  592. _sampleDetail.getAhSampleSheetDetail(id, res => {
  593. const {code,data,message} = res;
  594. if(code === 200){
  595. this.sampleDetailInfo = res.data.ahSampleSheet;
  596. this.sampleDetailInfo.sampleUnitName = this.sampleDetailInfo.sampleUnitName || res.data.AhZoneSampleCheck.checkUnitName;
  597. this.sampleDetailInfo.sampleAddress = this.sampleDetailInfo.sampleAddress || res.data.AhDictCheck.address;
  598. this.sampleDetailInfo.sampleId =this.sampleDetailInfo.sampleId || res.data.AhZoneSampleCheck.checkId;
  599. this.sampleDetailInfo.sampleContactName = this.sampleDetailInfo.sampleContactName || this.userinfo.name;
  600. this.sampleDetailInfo.sampleContactPhone =this.sampleDetailInfo.sampleContactPhone || res.data.AhDictCheck.phone;
  601. this.photo.groupPhoto = this.sampleDetailInfo.groupPhoto;
  602. this.photo.sealingPhoto = this.sampleDetailInfo.sealingPhoto;
  603. this.photo.sampleSheetPhoto = this.sampleDetailInfo.sampleSheetPhoto;
  604. const status = this.sampleDetailInfo.sampleStatus;
  605. const filledPeopleId = this.sampleDetailInfo.filledPeopleId;
  606. const commitPeopleId = this.sampleDetailInfo.commitPeopleId;
  607. // this.submitSampleSheet();
  608. if((filledPeopleId && this.userinfo.id !== filledPeopleId) || commitPeopleId){
  609. this.input_diabled = true;
  610. }
  611. if(this.sampleDetailInfo.qydm){
  612. //加载主体的基地信息
  613. this.getBaseByCheckList(this.sampleDetailInfo.qydm);
  614. //加载产品信息
  615. if(this.sampleDetailInfo.baseNumber){
  616. this.getProductBatchList({
  617. qydm: this.sampleDetailInfo.qydm,
  618. baseNumber: this.sampleDetailInfo.baseNumber
  619. });
  620. }
  621. }
  622. //status === "SAMPLE_FILLED" ||
  623. /*if (status === "SAMPLE_REPORT" || status === "CHECK_REPORT") {
  624. this.input_diabled = true;
  625. } else {
  626. this.input_diabled = false;
  627. }*/
  628. //查询抽样样品信息
  629. this.getSampleSheetDetailData();
  630. }else{
  631. this.$msg(message);
  632. this.input_diabled = true;
  633. }
  634. });
  635. },
  636. saveSampleInfoList() {
  637. _sampleDetail.updateAhSampleSheet(this.sampleDetailInfo, res => {
  638. const { code, message } = res;
  639. if (code !== 200) {
  640. this.$msg(message);
  641. }
  642. });
  643. },
  644. publishSampleSheet(){
  645. if(!this.ahSampleDetailList.some(v=>v.name === this.sampleDetailInfo.mustProductName)){
  646. this.$msg("抽样样本必须包含"+this.sampleDetailInfo.mustProductName);
  647. return
  648. }
  649. if (!this.sampleDetailInfo.samplingPeopleSecondId) {
  650. this.$msg("请选择同行抽样人员");
  651. return
  652. }
  653. if (!this.photo.sampleSheetPhoto) {
  654. this.$msg("请上传抽样单照片");
  655. return
  656. }
  657. if (!this.photo.sealingPhoto) {
  658. this.$msg("请上传封样照片");
  659. return
  660. }
  661. if (!this.photo.groupPhoto) {
  662. this.$msg("请上传抽样人员合影照片");
  663. return
  664. }
  665. const data = Object.assign(this.sampleDetailInfo, this.photo);
  666. uni.showModal({
  667. title: "提示",
  668. content: "确定上报当前抽样单",
  669. cancelText: "取消",
  670. confirmText: "确认",
  671. success: res => {
  672. if (res.confirm) {
  673. _sampleDetail.uploadCheckPhoto(data, res => {
  674. const {code, message} = res;
  675. if (code === 200) {
  676. _sampleDetail.publishSampleSheet(this.sampleDetailInfo.id,saveRes=>{
  677. const {code,message} = saveRes;
  678. if(code === 200){
  679. this.$msg("上报成功");
  680. setTimeout(()=>{
  681. uni.navigateBack({
  682. delta: 1
  683. });
  684. },1500)
  685. } else {
  686. this.$msg(message);
  687. }
  688. })
  689. }else{
  690. this.$msg(message);
  691. }
  692. });
  693. }
  694. }})
  695. },
  696. submitSampleSheet(){
  697. uni.showModal({
  698. title: "提示",
  699. content: "确认完成当前抽样单",
  700. cancelText: "取消",
  701. confirmText: "确认",
  702. success: res => {
  703. if (res.confirm) {
  704. _sampleDetail.submitSampleSheet(this.sampleDetailInfo.id,res=>{
  705. const {code,message} = res;
  706. if(code === 200){
  707. this.$msg("确认成功");
  708. setTimeout(()=>{
  709. uni.navigateBack({
  710. delta: 1
  711. });
  712. },1500)
  713. } else {
  714. this.$msg(message);
  715. }
  716. })
  717. }
  718. }})
  719. },
  720. /**
  721. * 新增样品信息
  722. */
  723. createAhSampleDetail() {
  724. if(this.ahSampleDetailList.length <= 0){
  725. this.saveSampleInfoList();
  726. }
  727. const ahSampleDetail = this.ahSampleDetail;
  728. if(!ahSampleDetail.name){
  729. this.$msg("请选择抽样产品");
  730. return
  731. }
  732. if(this.ahSampleDetailList.filter(v=>v.name === ahSampleDetail.name).length >= 2){
  733. this.$msg("同一产品最多可抽2个样");
  734. return
  735. }
  736. ahSampleDetail.sampleSheetId = this.sampleDetailInfo.id;
  737. if (!this.sourceType) {
  738. this.$msg("请选择样品来源");
  739. return false;
  740. }
  741. if ("" + this.sourceType === "1") {
  742. ahSampleDetail.source = "自产";
  743. }
  744. if ("" + this.sourceType !== "1" && !ahSampleDetail.source) {
  745. this.$msg("请输入来源详细地址");
  746. return false;
  747. }
  748. if (ahSampleDetail.hasOwnProperty("id")) {
  749. _sampleDetail.updateAhSampleDetail(this.ahSampleDetail, res => {
  750. const { code, message } = res;
  751. if (code === 200) {
  752. this.$msg("保存成功");
  753. this.modalName = null;
  754. this.getSampleSheetDetailData();
  755. this.ahSampleDetail= {};
  756. } else {
  757. this.$msg(message);
  758. }
  759. });
  760. } else {
  761. _sampleDetail.createAhSampleDetail(this.ahSampleDetail, res => {
  762. const { code, message } = res;
  763. if (code === 200) {
  764. this.$msg("保存成功");
  765. this.modalName = null;
  766. this.getSampleSheetDetailData();
  767. this.ahSampleDetail= {};
  768. } else {
  769. this.$msg(message);
  770. }
  771. });
  772. }
  773. },
  774. hideModal(e) {
  775. this.modalName = null;
  776. },
  777. getBaseByCheckList(qydm) {
  778. _sampleDetail.getBaseByCheckList(qydm, res => {
  779. const {data} = res;
  780. if (data.length === 0) {
  781. this.$msg("该主体未上报基地信息");
  782. } else {
  783. data.unshift({
  784. baseNumber: "",
  785. baseName: "请选择"
  786. });
  787. this.baseList = data;
  788. this.baseSelectList = data.map(v => v.baseName);
  789. if (this.sampleDetailInfo.qydm === qydm && !!this.sampleDetailInfo.baseNumber) {
  790. this.baseSelectIndex = data.findIndex(v => v.baseNumber === this.sampleDetailInfo.baseNumber);
  791. if (this.baseSelectIndex < 0) this.baseSelectIndex = 0;
  792. }
  793. }
  794. });
  795. },
  796. /**
  797. * 根据主体和基地查询产品列表
  798. */
  799. getProductBatchList({ qydm, baseNumber }) {
  800. _sampleDetail.getProductBatchList({ qydm, baseNumber }, res => {
  801. const {data} = res;
  802. if (data.length === 0) {
  803. this.$msg("该基地未上传产品信息");
  804. } else {
  805. this.productList = data.map(v => v.productName+"("+v.batchId+")");
  806. this.productList.unshift("请选择");
  807. this.serviceProductList = data;
  808. this.serviceProductList.unshift({
  809. pproductName:"请选择"
  810. });
  811. }
  812. });
  813. },
  814. setDateHandle(data, target, value) {
  815. if (data.hasOwnProperty(target)) {
  816. data[target] = value;
  817. } else {
  818. this.$set(data, target, value);
  819. }
  820. },
  821. getSampleSheetDetailData() {
  822. _sampleDetail.getSampleSheetDetailData({
  823. sampleSheetId: this.sampleDetailInfo.id,
  824. pageNum: 1,
  825. pageSize: 100
  826. }, res => {
  827. const { code, message, data: { records } } = res;
  828. if (code === 200) {
  829. this.ahSampleDetailList = records;
  830. } else {
  831. this.$msg(message);
  832. }
  833. });
  834. },
  835. /**
  836. * 删除抽样样品
  837. * @param id
  838. * @param callBack
  839. */
  840. delSampleDetail(id) {
  841. uni.showModal({
  842. title: "提示",
  843. content: "确定要删除当前样本么",
  844. cancelText: "取消",
  845. confirmText: "确认",
  846. success: res => {
  847. if (res.confirm) {
  848. _sampleDetail.delSampleDetail(id, res => {
  849. const {code,message} = res;
  850. if(code === 200){
  851. this.getSampleSheetDetailData();
  852. }else{
  853. this.$msg(message);
  854. }
  855. });
  856. }
  857. }
  858. });
  859. },
  860. editSampleDetail(index) {
  861. this.ahSampleDetail = this.ahSampleDetailList[index];
  862. if (this.ahSampleDetail.source !== "自产") {
  863. this.sourceType = "2";
  864. } else {
  865. this.sourceType = "1";
  866. }
  867. this.modalName = "addSimpleInfo";
  868. },
  869. showSecondCyUserChoose() {
  870. this.sampleDetailInfo.samplingPeopleSecond = null;
  871. this.modalName = "userListModal";
  872. },
  873. cyUserChange(e){
  874. const peopleId = e.detail.value;
  875. if (peopleId) {
  876. const person = this.cyUserList.find(v=>v.id === peopleId);
  877. this.sampleDetailInfo.samplingPeopleSecond = person.name;
  878. this.sampleDetailInfo.samplingPeopleSecondId = person.id;
  879. this.modalName = null;
  880. }else{
  881. this.sampleDetailInfo.samplingPeopleSecond = null;
  882. this.sampleDetailInfo.samplingPeopleSecondId = null;
  883. }
  884. },
  885. searchProduct() {
  886. this.pageNum = 1;
  887. this.pageTotal = 1;
  888. this.getCyUserList();
  889. },
  890. resetQymcQuery() {
  891. this.queryUserName = "";
  892. this.pageNum = 1;
  893. this.pageTotal = 1;
  894. this.getCyUserList();
  895. },
  896. getCyUserList() {
  897. if (this.pageNum === 1 || (this.pageNum <= this.pageTotal)) {
  898. _sampleDetail.getCyUserList({
  899. pageNum: this.pageNum,
  900. pageSize: this.pageSize,
  901. name: this.queryUserName
  902. }, res => {
  903. const { data, message, code } = res;
  904. if (code === 200) {
  905. this.cyUserList = data;
  906. /*const { list, total } = data;
  907. this.totalCount = total;
  908. this.pageTotal = Math.ceil(total / this.pageSize);
  909. if (this.pageNum === 1) {
  910. this.cyUserList = list;
  911. } else {
  912. this.cyUserList = this.cyUserList.concat(list);
  913. }
  914. this.pageNum++;*/
  915. } else {
  916. uni.showToast({
  917. icon: "none",
  918. title: message,
  919. duration: 1000
  920. });
  921. }
  922. });
  923. }
  924. },
  925. }
  926. };
  927. </script>
  928. <style scoped>
  929. .page {
  930. /*background-image: var(--gradualBlue);*/
  931. background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
  932. width: 100vw;
  933. overflow: hidden;
  934. }
  935. .DrawerPage .nav .cu-item.cur {
  936. border-bottom: 4rpx solid;
  937. }
  938. .DrawerPage .nav .cu-item.cur::after {
  939. content: none;
  940. }
  941. /*.nav .cu-item{
  942. height: 70rpx;
  943. line-height: 70rpx;
  944. }*/
  945. .cu-modal.drawer-modal .cu-dialog {
  946. min-width: 85vw;
  947. }
  948. .btDialog {
  949. min-height: 80vh;
  950. }
  951. .detail view {
  952. height: 1.8em;
  953. line-height: 1.8em !important;
  954. border: none;
  955. color: gray;
  956. }
  957. label {
  958. padding-left: .5em;
  959. }
  960. .productScroll {
  961. height: 30em;
  962. max-height: 60vh;
  963. }
  964. .tools {
  965. display: flex;
  966. align-items: center;
  967. justify-content: space-between;
  968. padding: 20upx;
  969. }
  970. .fixedFootBtn {
  971. border-top: 1px solid #ddd;
  972. position: fixed;
  973. width: 100vw;
  974. bottom: 0;
  975. z-index: 1000;
  976. }
  977. </style>