MeasuredDialog.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <el-dialog
  3. v-dialogDrag
  4. title="实测结果"
  5. :visible.sync="visible"
  6. append-to-body
  7. width="800px"
  8. @open="baseDialogOpen"
  9. >
  10. <!-- 搜索工作栏 -->
  11. <el-form
  12. ref="form"
  13. :model="form"
  14. :rules="rules"
  15. label-width="55px"
  16. size="mini"
  17. >
  18. <el-row :gutter="10">
  19. <el-col :span="6" :offset="0">
  20. <el-form-item label="下限值">
  21. <el-input v-model="form.minValue" disabled />
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6" :offset="0">
  25. <el-form-item label="标准值">
  26. <el-input v-model="form.standValue" disabled />
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="6" :offset="0">
  30. <el-form-item label="上限值">
  31. <el-input v-model="form.maxValue" disabled />
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="6" :offset="0">
  35. <el-form-item label="版本">
  36. <el-input v-model="form.version" disabled />
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. </el-form>
  41. <!-- 列表 -->
  42. <el-table
  43. ref="table"
  44. :data="list"
  45. style="width: 100%"
  46. border
  47. size="mini"
  48. >
  49. <el-table-column prop="actual" align="center" label="实测值">
  50. <template slot-scope="scope">
  51. <el-input
  52. :ref="`auto-${scope.$index}`"
  53. v-model="scope.row.actual"
  54. :class="`auto-${scope.$index}`"
  55. oninput="value=value.replace(/^\D*(\d*(?:.\d{0,7})?).*$/g, '$1')"
  56. @keyup.enter.native="getQualified(scope.row,scope.$index)"
  57. @change="handleActualChange"
  58. />
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="qualified" align="center" label="是否合格">
  62. <template slot-scope="scope">
  63. <dict-tag :type="DICT_TYPE.MES_QUALITY_IPQC_SINGLE_RESULT" :value="scope.row.qualified" />
  64. </template>
  65. </el-table-column>
  66. <el-table-column align="center" label="操作" width="120">
  67. <template slot-scope="scope">
  68. <el-button
  69. v-hasPermi="['wms:material-item-actual:delete']"
  70. type="text"
  71. size="mini"
  72. class="text-danger"
  73. @click="handleDelete(scope.row)"
  74. >删除</el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <span slot="footer">
  79. <el-button @click="visible = false">取消</el-button>
  80. <el-button type="primary" :loading="ensureLoading" @click="handleEnsure">确认</el-button>
  81. </span>
  82. <!-- 分页组件 -->
  83. <pagination
  84. v-show="total > 0"
  85. :total="total"
  86. :page.sync="queryParams.pageNo"
  87. :limit.sync="queryParams.pageSize"
  88. @pagination="getList"
  89. />
  90. </el-dialog>
  91. </template>
  92. <script>
  93. import { createMaterialItemActual, deleteMaterialItemActual, getMaterialItemActualPage, exportMaterialItemActualExcel } from '@/api/wms/quality/iqcInspectionExecute'
  94. export default {
  95. name: 'MaterialItemActual',
  96. components: {
  97. },
  98. data() {
  99. return {
  100. visible: false,
  101. // 遮罩层
  102. loading: true,
  103. // 导出遮罩层
  104. exportLoading: false,
  105. // 显示搜索条件
  106. showSearch: true,
  107. // 总条数
  108. total: 0,
  109. // 检验项实测值列表
  110. list: [],
  111. ensureLoading: false,
  112. // 弹出层标题
  113. title: '',
  114. // 是否显示弹出层
  115. open: false,
  116. itemForm: {},
  117. itemLoading: false,
  118. // 查询参数
  119. queryParams: {
  120. pageNo: 1,
  121. pageSize: 10,
  122. materialItemResultId: null,
  123. qualified: null,
  124. actual: null,
  125. createTime: []
  126. },
  127. // 表单参数
  128. form: {
  129. version: ''
  130. },
  131. // 表单校验
  132. rules: {
  133. }
  134. }
  135. },
  136. methods: {
  137. /** 查询列表 */
  138. getList() {
  139. this.loading = true
  140. // 执行查询
  141. getMaterialItemActualPage(this.queryParams).then(response => {
  142. this.list = response.data.list
  143. this.list.push({ actual: '', qualified: '' })
  144. this.total = response.data.total
  145. // 光标自动聚焦
  146. const len = this.list.length
  147. this.$refs.table.$nextTick(() => {
  148. this.$refs['auto-' + (len - 1) ].focus()
  149. })
  150. }).finally(() => {
  151. this.loading = false
  152. })
  153. },
  154. /** 重置按钮操作 */
  155. resetQuery() {
  156. this.queryParams.pageNo = 1
  157. this.getList()
  158. },
  159. resetItemForm() {
  160. this.itemForm = {
  161. actual: undefined,
  162. qualified: '1'
  163. }
  164. this.resetForm('itemForm')
  165. },
  166. /** 删除按钮操作 */
  167. handleDelete(row) {
  168. const id = row.id
  169. this.$modal.confirm('是否确认删除检验项实测值编号为"' + id + '"的数据项?').then(function() {
  170. return deleteMaterialItemActual(id)
  171. }).then(() => {
  172. this.getList()
  173. this.$emit('completeMeasure')
  174. this.$modal.msgSuccess('删除成功')
  175. }).catch(() => {})
  176. },
  177. /** 导出按钮操作 */
  178. handleExport() {
  179. // 处理查询参数
  180. const params = { ...this.queryParams }
  181. params.pageNo = undefined
  182. params.pageSize = undefined
  183. this.$modal.confirm('是否确认导出所有检验项实测值数据项?').then(() => {
  184. this.exportLoading = true
  185. return exportMaterialItemActualExcel(params)
  186. }).then(response => {
  187. this.$download.excel(response, '检验项实测值.xls')
  188. this.exportLoading = false
  189. }).catch(() => {})
  190. },
  191. baseDialogOpen() {
  192. this.$nextTick(() => {
  193. this.resetQuery()
  194. })
  195. },
  196. // 小数点问题处理
  197. // getHandleNumber(val) {
  198. // return Math.round((parseFloat(val) * 10000000)) / 10000000
  199. // },
  200. // 实测值
  201. handleActualChange(v) {
  202. // this.getHandleNumber(v)
  203. },
  204. // 判断实测是否合格
  205. getQualified(row, index) {
  206. const { id: materialItemResultId } = this.form
  207. const { actual } = row
  208. const params = {
  209. actual,
  210. materialItemResultId
  211. }
  212. createMaterialItemActual(params).then(res => {
  213. row.qualified = res.data === 'true' ? '合格' : '不合格'
  214. this.getList()
  215. this.$emit('completeMeasure')
  216. }).finally(() => {
  217. })
  218. },
  219. // 确定
  220. handleEnsure() {
  221. const { id: materialItemResultId } = this.form
  222. const items = this.list.find(item => item.qualified === '' && item.actual !== '')
  223. if (items !== undefined) {
  224. const params = {
  225. actual: items.actual,
  226. materialItemResultId
  227. }
  228. this.ensureLoading = true
  229. createMaterialItemActual(params).then(res => {
  230. items.qualified = res.data === 'true' ? '合格' : '不合格'
  231. this.getList()
  232. this.visible = false
  233. this.$emit('completeMeasure')
  234. this.ensureLoading = false
  235. }).finally(res => {
  236. this.ensureLoading = false
  237. })
  238. } else {
  239. this.visible = false
  240. }
  241. }
  242. }
  243. }
  244. </script>