inspectionProjectReport.vue 15 KB

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