experimentReport.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <u-popup :show="show" @close="cancel" :closeable="false">
  3. <view class="mainBox">
  4. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="实验" @clickLeft="cancel">
  5. </uni-nav-bar>
  6. <view class="wrapper">
  7. <view class="herder_item">
  8. <view class="herder_text"></view>
  9. <view class="herder_view">
  10. 实验时间
  11. </view>
  12. </view>
  13. <view class="marginTop20">
  14. <uni-datetime-picker v-if="type=='edit'" type="datetime"
  15. v-model="form.experimentalTime"></uni-datetime-picker>
  16. <u-input v-else :disabled="true" placeholder=" " border="surround"
  17. :value="form.experimentalTime"></u-input>
  18. </view>
  19. <view class="herder_item marginTop20">
  20. <view class="herder_text"></view>
  21. <view class="herder_view">
  22. 执行标准
  23. </view>
  24. </view>
  25. <u--input suffixIcon="arrow-right" style="background-color:#fff ;" :disabledColor="'#ffffff'"
  26. :disabled="true" class="marginTop20" placeholder=" " border="surround"
  27. :value="getDictValue('质检标准类型', projectData.qualityStandardType+'')">
  28. </u--input>
  29. <view class="herder_item marginTop20">
  30. <view class="herder_text"></view>
  31. <view class="herder_view">
  32. 实验室
  33. </view>
  34. </view>
  35. <view class="marginTop20">
  36. <uni-data-picker v-if="type=='edit'" :disabled='type=="view"' v-model="form.workshopName"
  37. placeholder="请选择" :localdata="laboratoryList" @change="getWorkshopId">
  38. </uni-data-picker>
  39. <u-input v-else :disabled="true" placeholder=" " border="surround"
  40. :value="form.workshopName"></u-input>
  41. </view>
  42. <!-- <view class="herder_item marginTop20">
  43. <view class="herder_text"></view>
  44. <view class="herder_view">
  45. 实验设备
  46. </view>
  47. </view> -->
  48. <view v-for="(item, index) in form.experimentEquipmentList">
  49. <view class="herder_item marginTop20" @click="delEquipmentList(index)">
  50. <view class="herder_text"></view>
  51. <view class="herder_view">
  52. 实验设备{{(index + 1)}}
  53. </view>
  54. <u-icon name="trash-fill" style="margin-ledt: 10rpx;" color="red" v-if="type=='edit'"></u-icon>
  55. </view>
  56. <u--input class="marginTop20" readonly placeholder="请选择" border="surround" :disabled="type=='view'"
  57. @click.native="add(index,'experimentEquipmentList',2)" v-model="item.equipmentName">
  58. </u--input>
  59. <view class="herder_item marginTop20">
  60. <view class="herder_text"></view>
  61. <view class="herder_view">
  62. 开始时间
  63. </view>
  64. </view>
  65. <uni-datetime-picker v-if="type=='edit'" type="datetime" class="marginTop20"
  66. v-model="item.startTime"></uni-datetime-picker>
  67. <u-input v-else :disabled="true" placeholder=" " border="surround" class="marginTop20"
  68. :value="item.startTime"></u-input>
  69. <view class="herder_item marginTop20">
  70. <view class="herder_text"></view>
  71. <view class="herder_view">
  72. 结束时间
  73. </view>
  74. </view>
  75. <uni-datetime-picker v-if="type=='edit'" type="datetime" class="marginTop20"
  76. v-model="item.endTime"></uni-datetime-picker>
  77. <u-input v-else :disabled="true" placeholder=" " border="surround" class="marginTop20"
  78. :value="item.endTime"></u-input>
  79. <view class="herder_item marginTop20">
  80. <view class="herder_text"></view>
  81. <view class="herder_view">
  82. 运行参数
  83. </view>
  84. </view>
  85. <u-input class="marginTop20" placeholder="请输入内容" border="surround" :disabled="type=='view'"
  86. v-model="item.operatingParameters">
  87. </u-input>
  88. </view>
  89. <view class="marginTop20" v-if="type=='edit'">
  90. <view class="experimentP" @click="addExperimentEquipmentList"><u-icon name="plus-circle"
  91. style="margin-right: 10rpx;"></u-icon>添加实验设备
  92. </view>
  93. </view>
  94. <view class="herder_item marginTop20">
  95. <view class="herder_text"></view>
  96. <view class="herder_view">
  97. 工艺要求
  98. </view>
  99. </view>
  100. <u--textarea class="marginTop20" disabled placeholder=" " border="surround" autoHeight
  101. v-model="form.processRequirementsJson"></u--textarea>
  102. <view class="herder_item marginTop20">
  103. <view class="herder_text"></view>
  104. <view class="herder_view">
  105. 实验工具
  106. </view>
  107. <u-badge max="99" :value="form.toolJson.length"></u-badge>
  108. </view>
  109. <view class="marginTop20">
  110. <view class="experimentP" @click="addTool('toolJson')"><u-icon name="plus-circle"
  111. style="margin-right: 10rpx;"></u-icon> {{type=='view'?'查看实验工具':'添加实验工具'}}
  112. </view>
  113. </view>
  114. <view class="herder_item marginTop20">
  115. <view class="herder_text"></view>
  116. <view class="herder_view">
  117. 实验耗材
  118. </view>
  119. <u-badge max="99" :value="form.consumablesJson.length"></u-badge>
  120. </view>
  121. <view class="marginTop20">
  122. <view class="experimentP" @click="addTool('consumablesJson')"><u-icon name="plus-circle"
  123. style="margin-right: 10rpx;"></u-icon> {{type=='view'?'查看实验耗材':'添加实验耗材'}}
  124. </view>
  125. </view>
  126. <view class="herder_item marginTop20">
  127. <view class="herder_text"></view>
  128. <view class="herder_view">
  129. 实验结果
  130. </view>
  131. </view>
  132. <u--textarea class="marginTop20" placeholder="请输入内容" border="surround" autoHeight
  133. :disabled="type=='view'" v-model="form.resultsDescription"></u--textarea>
  134. <view class="herder_item marginTop20">
  135. <view class="herder_text"></view>
  136. <view class="herder_view">
  137. 实验结论
  138. </view>
  139. </view>
  140. <uni-data-picker v-if="type!='view'" class="marginTop20" v-model="form.results" placeholder="请选择" :localdata="[{
  141. text:'合格',value:1
  142. },{
  143. text:'不合格',value:2
  144. }]">
  145. </uni-data-picker>
  146. <u-input disabled v-else class="marginTop20" placeholder="请输入内容" border="surround"
  147. :value="form.results==2?'不合格':'合格'">
  148. </u-input>
  149. <view class="herder_item marginTop20">
  150. <view class="herder_text"></view>
  151. <view class="herder_view">
  152. 实验图片
  153. </view>
  154. </view>
  155. <view v-if="type!='view'" class="marginTop20 imgAdd" @click="chooseImage('imgUrl')">
  156. <u-icon name="camera"></u-icon>
  157. </view>
  158. <PreviewPhoto :type="type" @imagedelete="imagedelete" :imageList="imgUrl" />
  159. <view class="herder_item marginTop20">
  160. <view class="herder_text"></view>
  161. <view class="herder_view">
  162. 附件图片
  163. </view>
  164. </view>
  165. <view v-if="type!='view'" class="marginTop20 imgAdd" @click="chooseImage('attachmentUrl')">
  166. <u-icon name="camera"></u-icon>
  167. </view>
  168. <PreviewPhoto :type="type" @imagedelete="imagedelete1" :imageList="attachmentUrl" />
  169. </view>
  170. <view style="height: 84rpx;"></view>
  171. <view class="footerButton">
  172. <u-button @click="cancel" type="default" text="返回"></u-button>
  173. <u-button v-if="type!='view'" type="primary" @click="save" text="保存"></u-button>
  174. </view>
  175. </view>
  176. <u-popup :show="toolJsonShow" :closeable="false" v-if="toolJsonShow">
  177. <view style="min-height:400rpx;position:relative">
  178. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="toolKey=='toolJson'?'实验工具':'实验耗材'"
  179. @clickLeft="toolJsonShow=false">
  180. </uni-nav-bar>
  181. <view v-for="(item, index) in form[toolKey]" :key="index" style="position: relative;">
  182. <myCard :item="item" :index="index+1" :btnList="[{
  183. name: '删除',
  184. apiName: 'del',
  185. btnType: 'error ',
  186. type: '2',
  187. pageUrl: '',
  188. judge: [{
  189. fn: isBtn
  190. }],
  191. }]" :columns="columns()" @del="del(index)">
  192. <u-input slot="batchNo" placeholder="请输入" border="surround" :disabled="type=='view'"
  193. v-model="item.batchNo">
  194. </u-input>
  195. <u--textarea slot="remark" placeholder="请输入内容" border="surround" autoHeight
  196. :disabled="type=='view'" v-model="item.remark"></u--textarea>
  197. </myCard>
  198. </view>
  199. <view class="add" @click="add(-1,toolKey,1)" v-if="type=='edit'">
  200. <u-icon name="plus" color="#fff"></u-icon>
  201. </view>
  202. </view>
  203. </u-popup>
  204. </u-popup>
  205. </template>
  206. <script>
  207. const defForm = {
  208. experimentalTime: '',
  209. qualityStandardType: '',
  210. workshopId: '',
  211. workshopName: '',
  212. processRequirementsJson: '',
  213. resultsDescription: '',
  214. results: 1,
  215. experimentEquipmentList: [],
  216. imgUrl: [],
  217. attachmentUrl: [],
  218. toolJson: [],
  219. consumablesJson: [],
  220. correlationId: '',
  221. qualityStandardName: '',
  222. qualityStandardId: '',
  223. qualityWorkOrderId: '',
  224. }
  225. import dictMixns from '@/mixins/dictMixins'
  226. import {
  227. getFactoryarea,
  228. getByIdExperiment,
  229. saveExperiment,
  230. updateExperiment
  231. } from '@/api/inspectionWork/index.js'
  232. import PreviewPhoto from '@/pages/maintenance/check/components/PreviewPhoto.vue'
  233. import myCard from '@/pages/saleManage/components/myCard.vue'
  234. export default {
  235. mixins: [dictMixns],
  236. components: {
  237. PreviewPhoto,
  238. myCard
  239. },
  240. props: {
  241. type: {
  242. type: String,
  243. default: 'view'
  244. },
  245. },
  246. computed: {
  247. imgUrl() {
  248. return this.form.imgUrl.map(item => {
  249. return this.getFileUrl(item)
  250. })
  251. },
  252. attachmentUrl() {
  253. return this.form.attachmentUrl.map(item => {
  254. return this.getFileUrl(item)
  255. })
  256. }
  257. },
  258. data() {
  259. return {
  260. dateShow: false,
  261. toolJsonShow: false,
  262. form: {
  263. ...defForm
  264. },
  265. laboratoryList: [],
  266. show: false,
  267. currentIndex: '',
  268. currentKey: '',
  269. toolKey: '',
  270. projectData: {}
  271. }
  272. },
  273. created() {
  274. uni.$off('setProduceList')
  275. uni.$on('setProduceList', (data) => {
  276. if (this.currentKey == 'experimentEquipmentList') {
  277. this.$set(
  278. this.form[this.currentKey][this.currentIndex],
  279. 'equipmentId',
  280. data[0].id
  281. );
  282. this.$set(
  283. this.form[this.currentKey][this.currentIndex],
  284. 'equipmentName',
  285. data[0].name
  286. );
  287. } else {
  288. this.form[this.currentKey].push(...data)
  289. }
  290. })
  291. },
  292. onUnload() {
  293. uni.$off('setProduceList')
  294. },
  295. methods: {
  296. isBtn() {
  297. return this.type == 'edit'
  298. },
  299. columns() {
  300. console.log(this.toolKey, 'this.toolKey')
  301. if (this.toolKey == 'toolJson') {
  302. return [
  303. [{
  304. label: '工具名称:',
  305. prop: 'name',
  306. type: 'title',
  307. }],
  308. [{
  309. label: '型号:',
  310. prop: 'modelType'
  311. }],
  312. [{
  313. label: '编号:',
  314. prop: 'code'
  315. }],
  316. [{
  317. label: '操作:',
  318. prop: 'action',
  319. type: 'action',
  320. className: 'perce100',
  321. }],
  322. ]
  323. } else {
  324. return [
  325. [{
  326. label: '耗材名称:',
  327. prop: 'name',
  328. type: 'title',
  329. }],
  330. [{
  331. label: '编号:',
  332. prop: 'code'
  333. }],
  334. [{
  335. label: '批次号:',
  336. prop: 'batchNo',
  337. slot: 'batchNo',
  338. }],
  339. [{
  340. label: '浓度:',
  341. prop: 'specification',
  342. }],
  343. [{
  344. label: '来源:',
  345. prop: 'gys',
  346. }],
  347. [{
  348. label: '过程:',
  349. prop: 'remark',
  350. slot: 'remark',
  351. }],
  352. [{
  353. label: '操作:',
  354. prop: 'action',
  355. type: 'action',
  356. className: 'perce100',
  357. }],
  358. ]
  359. }
  360. },
  361. getFileUrl(item) {
  362. let fileNames = item.storePath.split('/')
  363. let url = this.apiUrl +
  364. '/main/file/getFile?objectName=' + item.storePath +
  365. '&fullfilename=' + fileNames[fileNames.length -
  366. 1]
  367. return url
  368. },
  369. getWorkshopId({
  370. detail
  371. }) {
  372. if (detail.value[0]) {
  373. this.form.workshopId = detail.value[0].value
  374. } else {
  375. this.form.workshopId = ''
  376. }
  377. },
  378. add(index, key, type) {
  379. this.currentIndex = index;
  380. this.currentKey = key
  381. uni.navigateTo({
  382. url: '/pages/purchasingManage/components/selectProduce?isAll=' + type
  383. })
  384. },
  385. imagedelete(index) {
  386. this.form.imgUrl.splice(index, 1);
  387. },
  388. imagedelete1(index) {
  389. this.form.attachmentUrl.splice(index, 1);
  390. },
  391. addTool(key) {
  392. this.toolKey = key
  393. this.toolJsonShow = true
  394. },
  395. del(index) {
  396. this.form[this.toolKey].splice(index, 1);
  397. },
  398. delEquipmentList(index) {
  399. if (this.view == 'view') {
  400. return
  401. }
  402. this.form.experimentEquipmentList.splice(index, 1);
  403. },
  404. async open(row, type) {
  405. this.projectData = row
  406. if (row.experimentId) {
  407. this.$set(this, 'form', await getByIdExperiment(row.experimentId));
  408. } else {
  409. this.form.correlationId = row.id;
  410. this.form.qualityStandardName = row.qualityStandardName;
  411. this.form.qualityStandardId = row.qualityStandardId;
  412. this.form.qualityWorkOrderId = row.qualityWorkOrderId;
  413. if (row.symbol) {
  414. this.form.processRequirementsJson += row.symbol;
  415. }
  416. if (row.textType == 3) {
  417. this.form.processRequirementsJson +=
  418. row.minValue + '-' + row.maxValue;
  419. } else {
  420. this.form.processRequirementsJson += row.defaultValue;
  421. }
  422. if (row.unitName) {
  423. this.form.processRequirementsJson += row.unitName;
  424. }
  425. }
  426. getFactoryarea({
  427. pageNum: 1,
  428. size: 1000,
  429. type: 3
  430. }).then(res => {
  431. this.laboratoryList = res.list.map(item => {
  432. return {
  433. text: item.workshopName,
  434. value: item.workshopId
  435. }
  436. })
  437. })
  438. this.show = true
  439. // this.init()
  440. },
  441. chooseImage(key) {
  442. const _this = this
  443. uni.chooseImage({
  444. count: 9, //默认9
  445. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  446. sourceType: ['camera'], //从相册选择
  447. success: function(res) {
  448. uni.showLoading({
  449. title: '加载中'
  450. })
  451. _this.uploadFile(res.tempFilePaths).then(res => {
  452. _this.form[key].push(...res)
  453. console.log(this.form)
  454. // res.forEach(item => {
  455. // let fileNames = item.storePath.split('/')
  456. // let url = _this.apiUrl +
  457. // '/main/file/getFile?objectName=' + item.storePath +
  458. // '&fullfilename=' + fileNames[fileNames.length -
  459. // 1]
  460. // _this.imgs.push(url)
  461. // })
  462. uni.hideLoading()
  463. })
  464. }
  465. });
  466. },
  467. uploadFile(list) {
  468. let PromiseAll = []
  469. const apiUrl = this.apiUrl
  470. const token = uni.getStorageSync("token"); //取存本地的token
  471. list.forEach(item => {
  472. PromiseAll.push(
  473. new Promise((resolve, reject) => {
  474. uni.uploadFile({
  475. url: apiUrl + '/main/file/upload',
  476. filePath: item,
  477. name: 'multiPartFile',
  478. header: {
  479. authorization: token
  480. },
  481. success: (uploadFileRes) => {
  482. let data = JSON.parse(uploadFileRes.data)
  483. resolve(data.data)
  484. }
  485. });
  486. }),
  487. )
  488. })
  489. return Promise.all(PromiseAll)
  490. },
  491. cancel() {
  492. this.form = {
  493. ...defForm
  494. }
  495. this.show = false;
  496. },
  497. addExperimentEquipmentList() {
  498. this.form.experimentEquipmentList.push({});
  499. },
  500. save() {
  501. // if (!this.form.qualityResultContent) {
  502. // this.$refs.uToast.show({
  503. // type: "error",
  504. // icon: false,
  505. // message: "请填写质检内容!",
  506. // }, )
  507. // return
  508. // }
  509. // if (!this.form.sampleQuantity) {
  510. // this.$refs.uToast.show({
  511. // type: "error",
  512. // icon: false,
  513. // message: "请填写样品数!",
  514. // }, )
  515. // return
  516. // }
  517. let api = this.form.id ? updateExperiment : saveExperiment
  518. api(this.form)
  519. .then((msg) => {
  520. this.$emit('experimentReportSuccess', {
  521. workId: this.form.qualityWorkOrderId,
  522. projectId: this.projectData.id,
  523. })
  524. this.cancel()
  525. })
  526. .catch((e) => {
  527. this.cancel()
  528. });
  529. },
  530. }
  531. }
  532. </script>
  533. <style lang="scss" scoped>
  534. .mainBox {
  535. background-color: #f3f8fb;
  536. height: 100vh;
  537. font-size: 27rpx;
  538. overflow-y: auto;
  539. }
  540. .footerButton {
  541. width: 100%;
  542. height: 84rpx;
  543. display: flex;
  544. position: fixed;
  545. bottom: 0;
  546. z-index: 10;
  547. background-color: #fff;
  548. /deep/.u-button {
  549. height: 100%;
  550. }
  551. >view {
  552. flex: 1;
  553. }
  554. }
  555. /deep/.uni-textarea {
  556. padding: 0
  557. }
  558. /deep/.input-value {
  559. font-size: 28rpx !important;
  560. height: 70rpx
  561. }
  562. .defValue {
  563. color: #c1353c;
  564. text-indent: 2ch;
  565. }
  566. .marginTop20 {
  567. margin-top: 30rpx;
  568. }
  569. .herder_item {
  570. display: flex;
  571. font-weight: bold;
  572. // font-size: 26rpx;
  573. .herder_text {
  574. min-width: 10rpx;
  575. height: 32rpx;
  576. border-radius: 10rpx;
  577. background: #00c0a1;
  578. margin-right: 12rpx;
  579. margin-top: 5rpx;
  580. }
  581. }
  582. .wrapper {
  583. width: 720rpx;
  584. background: #fff;
  585. margin: 20rpx auto 0;
  586. border-radius: 30rpx;
  587. padding: 26rpx;
  588. }
  589. .experimentP {
  590. width: 100%;
  591. background-color: #f7f8fa;
  592. border-radius: 20rpx;
  593. height: 80rpx;
  594. justify-content: center;
  595. align-items: center;
  596. display: flex;
  597. font-weight: 800;
  598. }
  599. .imgAdd {
  600. width: 160rpx;
  601. height: 160rpx;
  602. background-color: #f7f8fa;
  603. border-radius: 20rpx;
  604. display: flex;
  605. justify-content: center;
  606. align-items: center;
  607. }
  608. .add {
  609. width: 96rpx;
  610. height: 96rpx;
  611. border-radius: 48rpx;
  612. background: #3c9cff;
  613. position: absolute;
  614. bottom: 50rpx;
  615. right: 24rpx;
  616. display: flex;
  617. align-items: center;
  618. justify-content: center;
  619. }
  620. </style>