BaseFormMeasure.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card">
  3. <a-row :gutter="48" style="position:fixed;bottom:150px;z-index:999;display:flex; justify-content: center;width: 90%;">
  4. <a-col :md="48" :sm="48">
  5. <span>
  6. <a-button type="primary" @click="save()">保存</a-button>
  7. <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
  8. </span>
  9. </a-col>
  10. </a-row>
  11. <div>
  12. <div class="tables">
  13. <div style="text-align:center;padding-bottom:10px;font-size:32px;">时代思康检定表</div>
  14. <div style="display:flex; justify-content: space-between;">
  15. <div> 检定人:{{ username }}</div>
  16. </div>
  17. <table>
  18. <thead border="1px">
  19. <tr>
  20. <th width="100px">序号</th>
  21. <th width="150px">设备名称</th>
  22. <th width="150px">型号</th>
  23. <th width="150px">是否是子设备</th>
  24. <th width="350px">选择父设备</th>
  25. <th width="150px">设备位置</th>
  26. <th width="150px">设备位号</th>
  27. <th width="150px">检定周期</th>
  28. <th width="150px">检定单号</th>
  29. <th width="150px">检定日期</th>
  30. <th width="150px">检定单位</th>
  31. <th width="150px">备注</th>
  32. <th width="150px">操作</th>
  33. </tr>
  34. <tr v-if="ListForm.length>0">
  35. <th v-for="item in ListForm[0].content" :key="item.name">{{ item.name }}</th>
  36. </tr>
  37. </thead>
  38. <tbody v-if="ListForm.length>0">
  39. <tr v-for="(item,i) in ListForm" :key="item.id">
  40. <td>{{ i+1 }}</td>
  41. <td>{{ item.sbName }}</td>
  42. <td>{{ item.sbModel }}</td>
  43. <td>{{ item.isChild === 1?'是':'否' }}</td>
  44. <td> <div v-if="item.isChild === 1" style="width:300px">
  45. <a-input
  46. disabled
  47. style="width: 50%"
  48. v-model="item.parentSbName"/>
  49. <a-button type="primary" @click="handleSbSelect(i)">选择</a-button>
  50. </div>
  51. <div v-else>无</div></td>
  52. <td><a-tree-select
  53. style="width: 150px"
  54. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  55. :treeData="treeData"
  56. :treeNodeFilterProp="'title'"
  57. :showSearch="true"
  58. v-model="item.sbPositionId"
  59. placeholder="请选择"
  60. >
  61. </a-tree-select></td>
  62. <td>
  63. <a-input v-if="item.isChild !== 1" style="width: 150px" v-model="item.sbPositionNo" />
  64. <div v-else style="width:300px">
  65. <a-input
  66. disabled
  67. style="width: 50%"
  68. v-model="item.sbPositionNo"/>
  69. <a-button type="primary" @click="handleSbNoSelect(i)">选择</a-button>
  70. </div>
  71. </td>
  72. <td><a-input v-model="item.checkPeriod" :formatter="BaseTool.Amount.formatter" :parser="BaseTool.Amount.parser"> <span slot="suffix" >月</span> </a-input></td>
  73. <td><a-input style="width: 150px" v-model="item.no" /></td>
  74. <td><a-date-picker
  75. placeholder="日期"
  76. style="width: 150px"
  77. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  78. v-model="item.lastDate" /></td>
  79. <td><a-input style="width: 150px" v-model="item.requirement" /></td>
  80. <td><a-input style="width: 150px" v-model="item.remark" /></td>
  81. <td>
  82. <a-button type="link" @click="uploadImg(item,i)">上传图片</a-button>
  83. <a-button type="link" @click="uploadFile(item,i)">上传文件</a-button>
  84. <a-modal v-model="uploadVisible" title="上传图片" :footer="null" @cancel="uploadVisible = false">
  85. <a-upload
  86. :action="uploadUrl"
  87. list-type="picture-card"
  88. :file-list="defaultApplicationFileList"
  89. @change="handleApplicationFileChange"
  90. @preview="handlePreview"
  91. accept="image/*"
  92. :headers="headers"
  93. >
  94. <div>
  95. <a-icon type="plus" />
  96. <div class="ant-upload-text">
  97. Upload
  98. </div>
  99. </div>
  100. </a-upload>
  101. </a-modal>
  102. <a-modal v-model="uploadFiledVisible" title="上传文件" :footer="null" @cancel="uploadFiledVisible = false">
  103. <a-upload
  104. :action="uploadUrl"
  105. :multiple="true"
  106. :file-list="defaultCheckFileList"
  107. @change="handleCheckFileChange"
  108. :headers="headers"
  109. >
  110. <a-button> <a-icon type="upload" /> 上传 </a-button>
  111. </a-upload>
  112. </a-modal>
  113. <a-modal :visible="previewVisible" :footer="null" @cancel="previewVisible = false" @ok="previewVisible = false">
  114. <img alt="example" style="width: 100%" :src="previewImage" />
  115. </a-modal>
  116. </td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. </div>
  121. </div>
  122. <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  123. <sb-position-no-modal ref="sbPositionNoModal" @selected="handleSbNoSelectd"/>
  124. </a-card>
  125. </template>
  126. <script>
  127. import { getSbPositionTree } from '@/api/sb/position'
  128. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  129. import SbPositionNoModal from '@/views/sb/info/modules/SbPositionNoModal'
  130. import { importMeasure } from '@/api/sb/info'
  131. import { uploadUrl } from '@/api/upms/file'
  132. import Vue from 'vue'
  133. import { ACCESS_TOKEN } from '@/store/mutation-types'
  134. import { status } from 'nprogress'
  135. export default {
  136. name: 'BaseFillGatherTask',
  137. components: {
  138. SbInfoSelectModal,
  139. SbPositionNoModal
  140. },
  141. data () {
  142. return {
  143. uploadUrl: uploadUrl,
  144. defaultApplicationFileList: [],
  145. defaultCheckFileList: [],
  146. checkFileList: [], // 文档
  147. applicationFileList: [],
  148. headers: {
  149. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  150. },
  151. visible: false,
  152. username: this.$store.getters.userInfo.username,
  153. uploadVisible: false,
  154. uploadFiledVisible: false,
  155. previewVisible: false,
  156. previewImage: '',
  157. treeData: [],
  158. sbParentOPt: 0,
  159. model: {},
  160. listPage: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. total: 0
  164. },
  165. pagination: {
  166. pageNum: 1,
  167. pageSize: 10,
  168. total: 0
  169. },
  170. imgId: '',
  171. fileId: '',
  172. ListForm: [],
  173. id: '',
  174. updatesInfo: []
  175. // 下拉框map
  176. }
  177. },
  178. props: {
  179. },
  180. created () {
  181. // 下拉框map
  182. },
  183. methods: {
  184. base (record) {
  185. this.visible = true
  186. this.model = record
  187. this.ListForm = record.map(item => {
  188. const data = {
  189. sbName: item.name,
  190. sbModel: item.model,
  191. checkPeriod: item.checkPeriod,
  192. isChild: item.isChild,
  193. parentSbName: item.parentSbName,
  194. sbParentId: item.parentId,
  195. sbPositionId: item.positionId,
  196. no: '',
  197. lastDate: '',
  198. sbPositionNo: item.positionNo,
  199. requirement: '',
  200. remark: '',
  201. name: this.username,
  202. sbId: item.id,
  203. type: 1,
  204. checkImgList: [],
  205. checkFileList: []
  206. }
  207. return data
  208. })
  209. getSbPositionTree().then(res => {
  210. this.treeData = res.data
  211. })
  212. },
  213. handleSbSelect (i) {
  214. this.sbParentOPt = i
  215. this.$refs.sbInfoSelectModal.base({}, { isChild: this.DictCache.VALUE.SB_IS_CHILD.IS_PARENT })
  216. },
  217. handleSbNoSelect (i) {
  218. this.sbParentOPt = i
  219. this.$refs.sbPositionNoModal.base()
  220. },
  221. handleSbSelectd (keys, rows) {
  222. console.log(keys, rows)
  223. this.ListForm[ this.sbParentOPt ].sbParentId = keys[0]
  224. this.ListForm[ this.sbParentOPt ].parentSbName = rows[0].name
  225. },
  226. handleSbNoSelectd (keys, rows) {
  227. console.log(keys, rows)
  228. this.ListForm[ this.sbParentOPt ].sbPositionNo = rows[0].no
  229. },
  230. uploadFile (val, i) {
  231. this.uploadFiledVisible = true
  232. this.fileId = i
  233. console.log(val)
  234. this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(val.checkFileList)
  235. },
  236. uploadImg (val, i) {
  237. this.uploadVisible = true
  238. console.log(val)
  239. this.imgId = i
  240. this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(val.checkImgList)
  241. },
  242. getBase64 (file) {
  243. return new Promise((resolve, reject) => {
  244. const reader = new FileReader()
  245. reader.readAsDataURL(file)
  246. reader.onload = () => resolve(reader.result)
  247. reader.onerror = error => reject(error)
  248. })
  249. },
  250. async handlePreview (file) {
  251. if (!file.url && !file.preview) {
  252. file.preview = await this.getBase64(file.originFileObj)
  253. }
  254. this.previewImage = file.url || file.preview
  255. this.previewVisible = true
  256. },
  257. handleApplicationFileChange (info) {
  258. this.defaultApplicationFileList = info.fileList
  259. this.applicationFileList = this.setFileList(info, 11)
  260. this.ListForm[this.imgId].checkImgList = this.applicationFileList
  261. },
  262. handleCheckFileChange (info) {
  263. this.defaultCheckFileList = info.fileList
  264. this.checkFileList = this.setFileList(info, 32)
  265. this.ListForm[this.fileId].checkFileList = this.checkFileList
  266. console.log(this.checkFileList)
  267. },
  268. setFileList (info, type) {
  269. const file = info.file
  270. const fileList = info.fileList
  271. if (file.status === 'done') {
  272. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  273. } else if (file.status === 'removed') {
  274. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  275. } else if (file.status === 'error') {
  276. this.$message.error('上传失败')
  277. return []
  278. }
  279. },
  280. save () {
  281. let status = false
  282. this.ListForm.forEach(item => {
  283. switch (true) {
  284. case item.no == '':
  285. this.$message.warning(item.sbName + '的检定单号不能为空!')
  286. status = true
  287. break
  288. case item.lastDate == '':
  289. this.$message.warning(item.sbName + '的检定日期不能为空!')
  290. status = true
  291. break
  292. }
  293. item.lastDate = item.lastDate != '' ? this.BaseTool.Date.formatter(item.lastDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : ''
  294. })
  295. if (status) return
  296. const params = {
  297. sbMeasureLogDTOList: this.ListForm
  298. }
  299. importMeasure(params).then(res => {
  300. this.$message.success('检定完成!')
  301. this.handleCancel()
  302. })
  303. },
  304. handleCancel () {
  305. this.visible = false
  306. this.ListForm = []
  307. this.$emit('ok')
  308. }
  309. }
  310. }
  311. </script>
  312. <style lang="less" scoped>
  313. .tables{
  314. margin: 20px 0px;
  315. width: 100%;
  316. overflow-x:auto;
  317. table {
  318. min-width:100%;
  319. margin: 0 auto;
  320. border: 1px solid #D6D6D6;
  321. border-collapse: collapse;
  322. font-size: 16px;
  323. font-weight: 400;
  324. table-layout:fixed;
  325. }
  326. th{
  327. background: #fafafa;
  328. font-weight: 500;
  329. }
  330. th,
  331. td {
  332. border: 1px solid #D6D6D6;
  333. text-align: center;
  334. padding: 5px 10px;
  335. white-space: nowrap;
  336. }
  337. }
  338. </style>