inspectionProjectReport.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="检验项目" @clickLeft="back">
  4. </uni-nav-bar>
  5. <view class="wrapper">
  6. <view class="herder_item">
  7. <view class="herder_text"></view>
  8. <view class="herder_view" style="font-size: 32rpx;">
  9. 检验信息({{form.status==1?'已检':form.status==2?'已派单':form.status==3?'已请托':'待检'}})
  10. </view>
  11. </view>
  12. <text class="marginTop20 tag">
  13. {{form.inspectionName}}
  14. </text>
  15. <view class="marginTop20 workValue">
  16. {{workData.productName}}/{{workData.code}}/{{workData.productCode}}
  17. </view>
  18. <view class="herder_item marginTop20">
  19. <view class="herder_text"></view>
  20. <view class="herder_view">
  21. 执行标准
  22. </view>
  23. </view>
  24. <u--input suffixIcon="arrow-right" style="background-color:#fff ;" :disabledColor="'#ffffff'"
  25. :disabled="true" class="marginTop20" placeholder=" " border="surround"
  26. :value="getDictValue('质检标准类型', form.qualityStandardType+'')"></u--input>
  27. <view class="herder_item marginTop20">
  28. <view class="herder_text"></view>
  29. <view class="herder_view">
  30. 工艺参数
  31. </view>
  32. </view>
  33. <view class="marginTop20 defValue">
  34. <text>{{ form.symbol }}</text>
  35. <text v-if="form.textType == 3">
  36. {{ form.minValue }}-{{ form.maxValue }}
  37. </text>
  38. <text v-else>
  39. <text>{{ form.defaultValue }}</text>
  40. </text>
  41. {{ form.unitName }}
  42. </view>
  43. <view class="herder_item marginTop20" v-if="form.executionMethod==2">
  44. <view class="herder_text"></view>
  45. <view class="herder_view">
  46. 实验数据
  47. </view>
  48. </view>
  49. <view class="marginTop20" v-if="form.executionMethod==2">
  50. <view style="width:150rpx">
  51. <u-button style="width:100rpx" type="primary" @click="open"
  52. :text="type=='edit'?'编辑':'查看'"></u-button>
  53. </view>
  54. </view>
  55. <view class="herder_item marginTop20" v-if="type=='edit'">
  56. <view class="herder_text"></view>
  57. <view class="herder_view">
  58. 工单剩余样品数
  59. </view>
  60. </view>
  61. <view class="marginTop20 " v-if="type=='edit'">
  62. <u-input disabled class="marginTop20" placeholder=" " border="surround"
  63. v-model="workData.remainingSampleCount">
  64. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}
  65. </template>
  66. </u-input>
  67. </view>
  68. <view class="herder_item marginTop20">
  69. <view class="herder_text"></view>
  70. <view class="herder_view">
  71. 质检内容
  72. </view>
  73. </view>
  74. <u-input :disabled='type=="view"' @change="handleInput(form, form.qualityResultContent)" class="marginTop20"
  75. placeholder="请输入内容" border="surround" v-model="form.qualityResultContent">
  76. <template slot="suffix" v-if="form.unitName">{{form.unitName}}</template>
  77. </u-input>
  78. <view class="herder_item marginTop20">
  79. <view class="herder_text"></view>
  80. <view class="herder_view">
  81. 样品数
  82. </view>
  83. </view>
  84. <u-input :disabled='type=="view"' @change="inputValue('sampleQuantity')" type="number" class="marginTop20"
  85. placeholder="请输入内容" border="surround" v-model="form.sampleQuantity">
  86. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  87. </u-input>
  88. <view class="herder_item marginTop20">
  89. <view class="herder_text"></view>
  90. <view class="herder_view">
  91. 合格数
  92. </view>
  93. </view>
  94. <u-input :disabled='type=="view"' type="number" @change="inputValue('qualifiedQuantity')"
  95. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.qualifiedQuantity">
  96. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  97. </u-input>
  98. <view class="herder_item marginTop20">
  99. <view class="herder_text"></view>
  100. <view class="herder_view">
  101. 不合格数
  102. </view>
  103. </view>
  104. <u-input :disabled='type=="view"' type="number" @change="inputValue('noQualifiedQuantity')"
  105. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.noQualifiedQuantity">
  106. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  107. </u-input>
  108. <view class="herder_item marginTop20">
  109. <view class="herder_text"></view>
  110. <view class="herder_view">
  111. 损耗数(合格品)
  112. </view>
  113. </view>
  114. <u-input :disabled='type=="view"' @change="inputValue('lossNumber')" type="number" class="marginTop20"
  115. placeholder="请输入内容" border="surround" v-model="form.lossNumber">
  116. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  117. </u-input>
  118. <view class="herder_item marginTop20">
  119. <view class="herder_text"></view>
  120. <view class="herder_view">
  121. 损耗数(不合格品)
  122. </view>
  123. </view>
  124. <u-input :disabled='type=="view"' @change="inputValue('lossNumberUnqualified')" type="number"
  125. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.lossNumberUnqualified">
  126. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  127. </u-input>
  128. <view class="herder_item marginTop20">
  129. <view class="herder_text"></view>
  130. <view class="herder_view">
  131. 留样数(合格品)
  132. </view>
  133. </view>
  134. <u-input :disabled='type=="view"' @change="inputValue('retainedSampleQuantity')" type="number"
  135. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleQuantity">
  136. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  137. </u-input>
  138. <view class="herder_item marginTop20">
  139. <view class="herder_text"></view>
  140. <view class="herder_view">
  141. 留样数(不合格品)
  142. </view>
  143. </view>
  144. <u-input :disabled='type=="view"' type="number" @change="inputValue('retainedSampleUnqualified')"
  145. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleUnqualified">
  146. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  147. </u-input>
  148. <view class="herder_item marginTop20">
  149. <view class="herder_text"></view>
  150. <view class="herder_view">
  151. 检验图片
  152. </view>
  153. </view>
  154. <fileMain class="marginTop20" v-model="form.inspectImage" :type="type=='view'?'view':'add'" ></fileMain>
  155. <view class="herder_item marginTop20">
  156. <view class="herder_text"></view>
  157. <view class="herder_view">
  158. 附件
  159. </view>
  160. </view>
  161. <fileMain class="marginTop20" v-model="form.imgUrl" type="view" ></fileMain>
  162. <view class="herder_item marginTop20">
  163. <view class="herder_text"></view>
  164. <view class="herder_view">
  165. 质检结果
  166. </view>
  167. </view>
  168. <uni-data-picker v-if="type=='edit'" class="marginTop20" v-model="form.qualityResults" placeholder="请选择"
  169. :localdata="acceptUnpackList">
  170. </uni-data-picker>
  171. <u-input disabled v-else class="marginTop20" placeholder="请输入内容" border="surround"
  172. :value="form.qualityResults&&acceptUnpackList.find(item=>item.value==form.qualityResults).text">
  173. </u-input>
  174. </view>
  175. <view class="footerButton">
  176. <u-button type="default" text="返回" @click="back"></u-button>
  177. <u-button v-if="type=='edit'" type="primary" @click="exeReportWorkBySingleTemplate" text="保存"></u-button>
  178. </view>
  179. <view style="width:100%;height: 100rpx;"></view>
  180. <u-toast ref="uToast"></u-toast>
  181. <experimentReport ref="experimentReportRef" @success="experimentReportSuccess" :type="type"></experimentReport>
  182. </view>
  183. </template>
  184. <script>
  185. import dictMixns from '@/mixins/dictMixins'
  186. import experimentReport from './experimentReport.vue'
  187. import fileMain from "@/pages/doc/index.vue";
  188. import {
  189. getById,
  190. exeReportWorkBySingleTemplate,
  191. exeReportWorkBySingleTaskmonad,
  192. exeReportWorkBySingleRequestentrust,
  193. getRequestentrustById,
  194. getTaskmonadById,
  195. verificationQualityInspector
  196. } from '@/api/inspectionWork/index.js'
  197. import {
  198. handleInput
  199. } from './unit.js';
  200. export default {
  201. components: {
  202. experimentReport,fileMain
  203. },
  204. mixins: [dictMixns],
  205. data() {
  206. return {
  207. handleInput,
  208. show: false,
  209. type: 'view',
  210. form: {
  211. lossNumber: '',
  212. lossNumberUnqualified: '',
  213. retainedSampleQuantity: '',
  214. retainedSampleUnqualified: '',
  215. qualifiedQuantity: '',
  216. noQualifiedQuantity: '',
  217. sampleQuantity: '',
  218. experimentId: '',
  219. inspectImage:[]
  220. },
  221. acceptUnpackList: [{
  222. text: "合格",
  223. value: 1
  224. },
  225. {
  226. text: "不合格",
  227. value: 2
  228. }, {
  229. text: "让步接收",
  230. value: 3
  231. },
  232. ],
  233. pageName: '',
  234. workData: {}
  235. }
  236. },
  237. computed: {
  238. },
  239. onLoad(data) {
  240. this.requestDict('质检计划类型');
  241. this.requestDict('取样类型');
  242. this.requestDict('质检标准类型');
  243. this.pageName = data.pageName
  244. if (data) {
  245. this.init(data)
  246. }
  247. },
  248. onShow() {
  249. },
  250. methods: {
  251. init(data) {
  252. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadById : this.pageName ==
  253. 'myInspectionProjectEntrusted' ? getRequestentrustById : getById
  254. api(data.workId).then(res => {
  255. this.workData = res
  256. this.$set(this, 'form', res.templateList.find(item => item.id == data.projectId))
  257. if (this.pageName == 'myInspectionProjectTask' && this.form.status == 2) {
  258. this.type = 'edit'
  259. }
  260. if (this.pageName == 'myInspectionProjectEntrusted' && this.form.status == 3) {
  261. this.type = 'edit'
  262. }
  263. if (this.form.status == 0) {
  264. this.type = 'edit'
  265. }
  266. this.form.measureUnit = data.sampleMeasureUnit || res.qualitySampleList[0]?.measureUnit
  267. })
  268. },
  269. experimentReportSuccess(data) {
  270. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadById : this.pageName ==
  271. 'myInspectionProjectEntrusted' ? getRequestentrustById : getById
  272. api(data.workId).then(res => {
  273. this.$set(this.form, 'experimentId', res.templateList.find(item => item.id == data.projectId)
  274. ?.experimentId)
  275. })
  276. },
  277. open() {
  278. this.$refs.experimentReportRef.open({
  279. ...this.form,
  280. qualityWorkOrderId: this.workData.id
  281. })
  282. },
  283. async exeReportWorkBySingleTemplate() {
  284. if (!this.pageName) {
  285. const code = await verificationQualityInspector(this.workData.id);
  286. if (code == '-1') {
  287. return;
  288. }
  289. }
  290. if (!this.form.qualityResultContent) {
  291. this.$refs.uToast.show({
  292. type: "error",
  293. icon: false,
  294. message: "请填写质检内容!",
  295. }, )
  296. return
  297. }
  298. if (!this.form.sampleQuantity) {
  299. this.$refs.uToast.show({
  300. type: "error",
  301. icon: false,
  302. message: "请填写样品数!",
  303. }, )
  304. return
  305. }
  306. this.form.status = 1
  307. let data = {
  308. id: this.workData.id,
  309. }
  310. let api = exeReportWorkBySingleTemplate
  311. if (this.pageName == 'myInspectionProjectTask') {
  312. api = exeReportWorkBySingleTaskmonad
  313. data.templateList = [this.form]
  314. } else if (this.pageName == "myInspectionProjectEntrusted") {
  315. api = exeReportWorkBySingleRequestentrust
  316. data.templateList = [this.form]
  317. } else {
  318. data.planTemplateList = [this.form]
  319. }
  320. api(data)
  321. .then((msg) => {
  322. uni.$emit('successInit')
  323. this.back()
  324. })
  325. .catch((e) => {
  326. this.back()
  327. });
  328. },
  329. valueInit(data) {
  330. ['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified'].forEach(
  331. key => {
  332. data[key] = ''
  333. })
  334. },
  335. inputValue(type) {
  336. if (this.type == 'view') {
  337. return
  338. }
  339. let data = JSON.parse(JSON.stringify((this.form)))
  340. if (data[type] < 0) {
  341. data[type] = '';
  342. }
  343. //样品数
  344. if (type == 'sampleQuantity') {
  345. if (+data[type] > this.workData.remainingSampleCount) {
  346. data[type] = 0
  347. this.$refs.uToast.show({
  348. type: "error",
  349. icon: false,
  350. message: "样品数不能大于工单剩余样品数",
  351. }, )
  352. }
  353. data.qualifiedQuantity = data[type]
  354. data.noQualifiedQuantity = 0
  355. this.valueInit(data)
  356. }
  357. //样品合格数、不合格数
  358. if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
  359. if (+data[type] > data.sampleQuantity) {
  360. data[type] = 0
  361. this.$refs.uToast.show({
  362. type: "error",
  363. icon: false,
  364. message: (type == 'qualifiedQuantity' ? '合格' : '不合格') + "数不能大于样品数",
  365. }, )
  366. }
  367. let key = type == 'qualifiedQuantity' ? 'noQualifiedQuantity' : 'qualifiedQuantity'
  368. data[key] = data.sampleQuantity - data[type]
  369. this.valueInit(data)
  370. }
  371. //损耗数 留样数
  372. if (['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified']
  373. .includes(type)) {
  374. if (type == 'lossNumber' || type == 'retainedSampleQuantity') {
  375. if (Number(data.lossNumber) + Number(data.retainedSampleQuantity) > data.qualifiedQuantity) {
  376. this.$refs.uToast.show({
  377. type: "error",
  378. icon: false,
  379. message: "损耗合格数与留样合格数之和不能大于样品合格数",
  380. }, )
  381. data[type] = ''
  382. }
  383. } else {
  384. if (Number(data.lossNumberUnqualified) + Number(data.retainedSampleUnqualified) > data
  385. .noQualifiedQuantity) {
  386. this.$refs.uToast.show({
  387. type: "error",
  388. icon: false,
  389. message: "损耗不合格数与留样不合格数之和不能大于样品不合格数",
  390. }, )
  391. data[type] = ''
  392. }
  393. }
  394. }
  395. this.$nextTick(() => {
  396. this.$set(this, 'form', JSON.parse(JSON.stringify((data))))
  397. })
  398. }
  399. }
  400. }
  401. </script>
  402. <style lang="scss" scoped>
  403. .mainBox {
  404. background-color: #f3f8fb;
  405. height: 100vh;
  406. font-size: 27rpx;
  407. overflow-y: auto;
  408. }
  409. .wrapper {
  410. width: 720rpx;
  411. background: #fff;
  412. margin: 20rpx auto 0;
  413. border-radius: 30rpx;
  414. padding: 26rpx;
  415. }
  416. .footerButton {
  417. width: 100%;
  418. height: 84rpx;
  419. display: flex;
  420. position: fixed;
  421. bottom: 0;
  422. z-index: 10;
  423. background-color: #fff;
  424. /deep/.u-button {
  425. height: 100%;
  426. }
  427. >view {
  428. flex: 1;
  429. }
  430. }
  431. .workValue {
  432. word-break: break-all;
  433. font-weight: bold;
  434. }
  435. .tag {
  436. // font-size: 24rpx;
  437. color: #fff;
  438. padding: 12rpx;
  439. border-radius: 10rpx;
  440. background: #979797;
  441. display: inline-block;
  442. }
  443. /deep/.input-value {
  444. font-size: 28rpx !important;
  445. }
  446. .defValue {
  447. color: #c1353c;
  448. text-indent: 2ch;
  449. }
  450. .marginTop20 {
  451. margin-top: 30rpx;
  452. }
  453. .herder_item {
  454. display: flex;
  455. font-weight: bold;
  456. // font-size: 26rpx;
  457. .herder_text {
  458. min-width: 10rpx;
  459. height: 32rpx;
  460. border-radius: 10rpx;
  461. background: #00c0a1;
  462. margin-right: 12rpx;
  463. margin-top: 5rpx;
  464. }
  465. }
  466. </style>