inspectionProjectReport.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. <uni-data-picker v-if="type=='edit'" class="marginTop20" v-model="form.qualityResults" placeholder="请选择"
  155. :localdata="acceptUnpackList">
  156. </uni-data-picker>
  157. <u-input disabled v-else class="marginTop20" placeholder="请输入内容" border="surround"
  158. :value="form.qualityResults&&acceptUnpackList.find(item=>item.value==form.qualityResults).text">
  159. </u-input>
  160. </view>
  161. <view class="footerButton">
  162. <u-button type="default" text="返回" @click="back"></u-button>
  163. <u-button v-if="type=='edit'" type="primary" @click="exeReportWorkBySingleTemplate" text="保存"></u-button>
  164. </view>
  165. <view style="width:100%;height: 100rpx;"></view>
  166. <u-toast ref="uToast"></u-toast>
  167. <experimentReport ref="experimentReportRef" @success="experimentReportSuccess" :type="type"></experimentReport>
  168. </view>
  169. </template>
  170. <script>
  171. import dictMixns from '@/mixins/dictMixins'
  172. import experimentReport from './experimentReport.vue'
  173. import {
  174. getById,
  175. exeReportWorkBySingleTemplate,
  176. exeReportWorkBySingleTaskmonad,
  177. exeReportWorkBySingleRequestentrust,
  178. getRequestentrustById,
  179. getTaskmonadById,
  180. verificationQualityInspector
  181. } from '@/api/inspectionWork/index.js'
  182. import {
  183. handleInput
  184. } from './unit.js';
  185. export default {
  186. components: {
  187. experimentReport
  188. },
  189. mixins: [dictMixns],
  190. data() {
  191. return {
  192. handleInput,
  193. show: false,
  194. type: 'edit',
  195. form: {
  196. lossNumber: '',
  197. lossNumberUnqualified: '',
  198. retainedSampleQuantity: '',
  199. retainedSampleUnqualified: '',
  200. qualifiedQuantity: '',
  201. noQualifiedQuantity: '',
  202. sampleQuantity: '',
  203. experimentId: ''
  204. },
  205. acceptUnpackList: [{
  206. text: "合格",
  207. value: 1
  208. },
  209. {
  210. text: "不合格",
  211. value: 2
  212. }, {
  213. text: "让步接收",
  214. value: 3
  215. },
  216. ],
  217. pageName: '',
  218. workData: {}
  219. }
  220. },
  221. computed: {
  222. },
  223. onLoad(data) {
  224. this.requestDict('质检计划类型');
  225. this.requestDict('取样类型');
  226. this.requestDict('质检标准类型');
  227. this.pageName = data.pageName
  228. if (data) {
  229. this.init(data)
  230. }
  231. },
  232. onShow() {
  233. },
  234. methods: {
  235. init(data) {
  236. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadById : this.pageName ==
  237. 'myInspectionProjectEntrusted' ? getRequestentrustById : getById
  238. api(data.workId).then(res => {
  239. this.workData = res
  240. this.$set(this, 'form', res.templateList.find(item => item.id == data.projectId))
  241. if (this.pageName == 'myInspectionProjectTask' && this.form.status == 2) {
  242. this.type = 'edit'
  243. }
  244. if (this.pageName == 'myInspectionProjectEntrusted' && this.form.status == 3) {
  245. this.type = 'edit'
  246. }
  247. if (this.form.status == 0) {
  248. this.type = 'edit'
  249. }
  250. this.form.measureUnit = data.sampleMeasureUnit || res.qualitySampleList[0]?.measureUnit
  251. })
  252. },
  253. experimentReportSuccess(data) {
  254. let api = this.pageName == 'myInspectionProjectTask' ? getTaskmonadById : this.pageName ==
  255. 'myInspectionProjectEntrusted' ? getRequestentrustById : getById
  256. api(data.workId).then(res => {
  257. this.$set(this.form, 'experimentId', res.templateList.find(item => item.id == data.projectId)
  258. ?.experimentId)
  259. })
  260. },
  261. open() {
  262. this.$refs.experimentReportRef.open({
  263. ...this.form,
  264. qualityWorkOrderId: this.workData.id
  265. }, 'add')
  266. },
  267. async exeReportWorkBySingleTemplate() {
  268. if (!this.pageName) {
  269. const code = await verificationQualityInspector(this.workData.id);
  270. if (code == '-1') {
  271. return;
  272. }
  273. }
  274. if (!this.form.qualityResultContent) {
  275. this.$refs.uToast.show({
  276. type: "error",
  277. icon: false,
  278. message: "请填写质检内容!",
  279. }, )
  280. return
  281. }
  282. if (!this.form.sampleQuantity) {
  283. this.$refs.uToast.show({
  284. type: "error",
  285. icon: false,
  286. message: "请填写样品数!",
  287. }, )
  288. return
  289. }
  290. this.form.status = 1
  291. let data = {
  292. id: this.workData.id,
  293. }
  294. let api = exeReportWorkBySingleTemplate
  295. if (this.pageName == 'myInspectionProjectTask') {
  296. api = exeReportWorkBySingleTaskmonad
  297. data.templateList = [this.form]
  298. } else if (this.pageName == "myInspectionProjectEntrusted") {
  299. api = exeReportWorkBySingleRequestentrust
  300. data.templateList = [this.form]
  301. } else {
  302. data.planTemplateList = [this.form]
  303. }
  304. api(data)
  305. .then((msg) => {
  306. uni.$emit('successInit')
  307. this.back()
  308. })
  309. .catch((e) => {
  310. this.back()
  311. });
  312. },
  313. valueInit(data) {
  314. ['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified'].forEach(
  315. key => {
  316. data[key] = ''
  317. })
  318. },
  319. inputValue(type) {
  320. if (this.type == 'view') {
  321. return
  322. }
  323. let data = JSON.parse(JSON.stringify((this.form)))
  324. if (data[type] < 0) {
  325. data[type] = '';
  326. }
  327. //样品数
  328. if (type == 'sampleQuantity') {
  329. if (+data[type] > this.workData.remainingSampleCount) {
  330. data[type] = 0
  331. this.$refs.uToast.show({
  332. type: "error",
  333. icon: false,
  334. message: "样品数不能大于工单剩余样品数",
  335. }, )
  336. }
  337. data.qualifiedQuantity = data[type]
  338. data.noQualifiedQuantity = 0
  339. this.valueInit(data)
  340. }
  341. //样品合格数、不合格数
  342. if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
  343. if (+data[type] > data.sampleQuantity) {
  344. data[type] = 0
  345. this.$refs.uToast.show({
  346. type: "error",
  347. icon: false,
  348. message: (type == 'qualifiedQuantity' ? '合格' : '不合格') + "数不能大于样品数",
  349. }, )
  350. }
  351. let key = type == 'qualifiedQuantity' ? 'noQualifiedQuantity' : 'qualifiedQuantity'
  352. data[key] = data.sampleQuantity - data[type]
  353. this.valueInit(data)
  354. }
  355. //损耗数 留样数
  356. if (['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified']
  357. .includes(type)) {
  358. if (type == 'lossNumber' || type == 'retainedSampleQuantity') {
  359. if (Number(data.lossNumber) + Number(data.retainedSampleQuantity) > data.qualifiedQuantity) {
  360. this.$refs.uToast.show({
  361. type: "error",
  362. icon: false,
  363. message: "损耗合格数与留样合格数之和不能大于样品合格数",
  364. }, )
  365. data[type] = ''
  366. }
  367. } else {
  368. if (Number(data.lossNumberUnqualified) + Number(data.retainedSampleUnqualified) > data
  369. .noQualifiedQuantity) {
  370. this.$refs.uToast.show({
  371. type: "error",
  372. icon: false,
  373. message: "损耗不合格数与留样不合格数之和不能大于样品不合格数",
  374. }, )
  375. data[type] = ''
  376. }
  377. }
  378. }
  379. this.$nextTick(() => {
  380. this.$set(this, 'form', JSON.parse(JSON.stringify((data))))
  381. })
  382. }
  383. }
  384. }
  385. </script>
  386. <style lang="scss" scoped>
  387. .mainBox {
  388. background-color: #f3f8fb;
  389. height: 100vh;
  390. font-size: 27rpx;
  391. overflow-y: auto;
  392. }
  393. .wrapper {
  394. width: 720rpx;
  395. background: #fff;
  396. margin: 20rpx auto 0;
  397. border-radius: 30rpx;
  398. padding: 26rpx;
  399. }
  400. .footerButton {
  401. width: 100%;
  402. height: 84rpx;
  403. display: flex;
  404. position: fixed;
  405. bottom: 0;
  406. z-index: 10;
  407. background-color: #fff;
  408. /deep/.u-button {
  409. height: 100%;
  410. }
  411. >view {
  412. flex: 1;
  413. }
  414. }
  415. .workValue {
  416. word-break: break-all;
  417. font-weight: bold;
  418. }
  419. .tag {
  420. // font-size: 24rpx;
  421. color: #fff;
  422. padding: 12rpx;
  423. border-radius: 10rpx;
  424. background: #979797;
  425. display: inline-block;
  426. }
  427. /deep/.input-value {
  428. font-size: 28rpx !important;
  429. }
  430. .defValue {
  431. color: #c1353c;
  432. text-indent: 2ch;
  433. }
  434. .marginTop20 {
  435. margin-top: 30rpx;
  436. }
  437. .herder_item {
  438. display: flex;
  439. font-weight: bold;
  440. // font-size: 26rpx;
  441. .herder_text {
  442. min-width: 10rpx;
  443. height: 32rpx;
  444. border-radius: 10rpx;
  445. background: #00c0a1;
  446. margin-right: 12rpx;
  447. margin-top: 5rpx;
  448. }
  449. }
  450. </style>