inspectionProjectReport.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. {{form.defaultValue}}
  35. </view>
  36. <view class="herder_item marginTop20">
  37. <view class="herder_text"></view>
  38. <view class="herder_view">
  39. 工单剩余样品数
  40. </view>
  41. </view>
  42. <view class="marginTop20 ">
  43. <u-input disabled class="marginTop20" placeholder=" " border="surround"
  44. v-model="workData.remainingSampleCount">
  45. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}
  46. </template>
  47. </u-input>
  48. </view>
  49. <view class="herder_item marginTop20">
  50. <view class="herder_text"></view>
  51. <view class="herder_view">
  52. 质检内容
  53. </view>
  54. </view>
  55. <u-input :disabled='form.status==1' @change="handleInput(form, form.qualityResultContent)"
  56. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.qualityResultContent">
  57. <template slot="suffix" v-if="form.unitName">{{form.unitName}}</template>
  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. <u-input :disabled='form.status==1' @change="inputValue('sampleQuantity')" type="number" class="marginTop20"
  66. placeholder="请输入内容" border="surround" v-model="form.sampleQuantity">
  67. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  68. </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. <u-input :disabled='form.status==1' type="number" @change="inputValue('qualifiedQuantity')"
  76. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.qualifiedQuantity">
  77. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  78. </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 :disabled='form.status==1' type="number" @change="inputValue('noQualifiedQuantity')"
  86. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.noQualifiedQuantity">
  87. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  88. </u-input>
  89. <view class="herder_item marginTop20">
  90. <view class="herder_text"></view>
  91. <view class="herder_view">
  92. 损耗数(合格品)
  93. </view>
  94. </view>
  95. <u-input :disabled='form.status==1' @change="inputValue('lossNumber')" type="number" class="marginTop20"
  96. placeholder="请输入内容" border="surround" v-model="form.lossNumber">
  97. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  98. </u-input>
  99. <view class="herder_item marginTop20">
  100. <view class="herder_text"></view>
  101. <view class="herder_view">
  102. 损耗数(不合格品)
  103. </view>
  104. </view>
  105. <u-input :disabled='form.status==1' @change="inputValue('lossNumberUnqualified')" type="number"
  106. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.lossNumberUnqualified">
  107. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  108. </u-input>
  109. <view class="herder_item marginTop20">
  110. <view class="herder_text"></view>
  111. <view class="herder_view">
  112. 留样数(合格品)
  113. </view>
  114. </view>
  115. <u-input :disabled='form.status==1' @change="inputValue('retainedSampleQuantity')" type="number"
  116. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleQuantity">
  117. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  118. </u-input>
  119. <view class="herder_item marginTop20">
  120. <view class="herder_text"></view>
  121. <view class="herder_view">
  122. 留样数(不合格品)
  123. </view>
  124. </view>
  125. <u-input :disabled='form.status==1' type="number" @change="inputValue('retainedSampleUnqualified')"
  126. class="marginTop20" placeholder="请输入内容" border="surround" v-model="form.retainedSampleUnqualified">
  127. <template slot="suffix" v-if="form.measureUnit">{{form.measureUnit}}</template>
  128. </u-input>
  129. <view class="herder_item marginTop20">
  130. <view class="herder_text"></view>
  131. <view class="herder_view">
  132. 质检结果
  133. </view>
  134. </view>
  135. <uni-data-picker v-if='form.status!=1' class="marginTop20" v-model="form.qualityResults" placeholder="请选择"
  136. :localdata="acceptUnpackList">
  137. </uni-data-picker>
  138. <u-input disabled v-else class="marginTop20" placeholder="请输入内容" border="surround"
  139. :value="acceptUnpackList.find(item=>item.value==form.qualityResults).text">
  140. </u-input>
  141. </view>
  142. <view class="footerButton">
  143. <u-button type="default" text="返回" @click="back"></u-button>
  144. <u-button v-if="form.status!=1" type="primary" @click="exeReportWorkBySingleTemplate" text="保存"></u-button>
  145. </view>
  146. <view style="width:100%;height: 100rpx;"></view>
  147. <u-toast ref="uToast"></u-toast>
  148. </view>
  149. </template>
  150. <script>
  151. import dictMixns from '@/mixins/dictMixins'
  152. import {
  153. getById,
  154. exeReportWorkBySingleTemplate
  155. } from '@/api/inspectionWork/index.js'
  156. import {
  157. handleInput
  158. } from './unit.js';
  159. export default {
  160. components: {},
  161. mixins: [dictMixns],
  162. data() {
  163. return {
  164. handleInput,
  165. show: false,
  166. form: {
  167. },
  168. acceptUnpackList: [{
  169. text: "合格",
  170. value: 1
  171. },
  172. {
  173. text: "不合格",
  174. value: 2
  175. }, {
  176. text: "让步接收",
  177. value: 3
  178. },
  179. ],
  180. workData: {}
  181. }
  182. },
  183. computed: {
  184. },
  185. onLoad(data) {
  186. this.requestDict('质检计划类型');
  187. this.requestDict('取样类型');
  188. this.requestDict('质检标准类型');
  189. if (data) {
  190. getById(data.workId).then(res => {
  191. this.workData = res
  192. this.form = res.templateList.find(item => item.id == data.projectId)
  193. this.form.measureUnit = res.qualitySampleList[0]?.measureUnit
  194. })
  195. }
  196. },
  197. onShow() {
  198. },
  199. methods: {
  200. exeReportWorkBySingleTemplate() {
  201. // let params = JSON.parse(JSON.stringify(this.workData))
  202. // let index = params.templateList.findIndex(item => item.id == this.form.id)
  203. // params.templateList[index] = this.form
  204. // params.
  205. if (!this.form.qualityResultContent) {
  206. this.$refs.uToast.show({
  207. type: "error",
  208. icon: false,
  209. message: "请填写质检内容!",
  210. }, )
  211. return
  212. }
  213. if (!this.form.sampleQuantity) {
  214. this.$refs.uToast.show({
  215. type: "error",
  216. icon: false,
  217. message: "请填写样品数!",
  218. }, )
  219. return
  220. }
  221. this.form.status = 1
  222. exeReportWorkBySingleTemplate({
  223. id: this.workData.id,
  224. planTemplateList: [this.form]
  225. })
  226. .then((msg) => {
  227. this.back()
  228. })
  229. .catch((e) => {
  230. this.back()
  231. });
  232. },
  233. valueInit(data) {
  234. ['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified'].forEach(
  235. key => {
  236. data[key] = 0
  237. })
  238. },
  239. inputValue(type) {
  240. console.log(type, 'type')
  241. let data = JSON.parse(JSON.stringify((this.form)))
  242. if (data[type] < 0) {
  243. data[type] = 0;
  244. }
  245. //样品数
  246. if (type == 'sampleQuantity') {
  247. if (+data[type] > this.workData.remainingSampleCount) {
  248. data[type] = 0
  249. this.$refs.uToast.show({
  250. type: "error",
  251. icon: false,
  252. message: "样品数不能大于工单剩余样品数",
  253. }, )
  254. }
  255. data.qualifiedQuantity = data[type]
  256. data.noQualifiedQuantity = 0
  257. this.valueInit(data)
  258. }
  259. //样品合格数、不合格数
  260. if (type == 'qualifiedQuantity' || type == 'noQualifiedQuantity') {
  261. if (+data[type] > data.sampleQuantity) {
  262. data[type] = 0
  263. this.$refs.uToast.show({
  264. type: "error",
  265. icon: false,
  266. message: (type == 'qualifiedQuantity' ? '合格' : '不合格') + "数不能大于样品数",
  267. }, )
  268. }
  269. let key = type == 'qualifiedQuantity' ? 'noQualifiedQuantity' : 'qualifiedQuantity'
  270. data[key] = data.sampleQuantity - data[type]
  271. this.valueInit(data)
  272. }
  273. //损耗数 留样数
  274. if (['lossNumber', 'lossNumberUnqualified', 'retainedSampleQuantity', 'retainedSampleUnqualified']
  275. .includes(type)) {
  276. if (type == 'lossNumber' || type == 'retainedSampleQuantity') {
  277. if (Number(data.lossNumber) + Number(data.retainedSampleQuantity) > data.qualifiedQuantity) {
  278. this.$refs.uToast.show({
  279. type: "error",
  280. icon: false,
  281. message: "损耗合格数与留样合格数之和不能大于样品合格数",
  282. }, )
  283. data[type] = 0
  284. }
  285. } else {
  286. if (Number(data.lossNumberUnqualified) + Number(data.retainedSampleUnqualified) > data
  287. .noQualifiedQuantity) {
  288. this.$refs.uToast.show({
  289. type: "error",
  290. icon: false,
  291. message: "损耗不合格数与留样不合格数之和不能大于样品不合格数",
  292. }, )
  293. data[type] = 0
  294. }
  295. }
  296. }
  297. this.$set(this, 'form', JSON.parse(JSON.stringify((data))))
  298. }
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped>
  303. .mainBox {
  304. background-color: #f3f8fb;
  305. height: 100vh;
  306. font-size: 27rpx;
  307. overflow-y: auto;
  308. }
  309. .wrapper {
  310. width: 720rpx;
  311. background: #fff;
  312. margin: 20rpx auto 0;
  313. border-radius: 30rpx;
  314. padding: 26rpx;
  315. }
  316. .footerButton {
  317. width: 100%;
  318. height: 84rpx;
  319. display: flex;
  320. position: fixed;
  321. bottom: 0;
  322. z-index: 10;
  323. background-color: #fff;
  324. /deep/.u-button {
  325. height: 100%;
  326. }
  327. >view {
  328. flex: 1;
  329. }
  330. }
  331. .workValue {
  332. word-break: break-all;
  333. font-weight: bold;
  334. }
  335. .tag {
  336. // font-size: 24rpx;
  337. color: #fff;
  338. padding: 12rpx;
  339. border-radius: 10rpx;
  340. background: #979797;
  341. display: inline-block;
  342. }
  343. /deep/.input-value {
  344. font-size: 28rpx !important;
  345. }
  346. .defValue {
  347. color: #c1353c;
  348. text-indent: 2ch;
  349. }
  350. .marginTop20 {
  351. margin-top: 30rpx;
  352. }
  353. .herder_item {
  354. display: flex;
  355. font-weight: bold;
  356. // font-size: 26rpx;
  357. .herder_text {
  358. min-width: 10rpx;
  359. height: 32rpx;
  360. border-radius: 10rpx;
  361. background: #00c0a1;
  362. margin-right: 12rpx;
  363. margin-top: 5rpx;
  364. }
  365. }
  366. </style>