DetailSbCheck.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div v-show="visible">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right">
  6. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  7. </span>
  8. </a-col>
  9. </a-row>
  10. <title-divider title="设备信息" width="90px"></title-divider>
  11. <detail-list title="" :col="3">
  12. <detail-list-item term="设备新号">{{ model.no }}</detail-list-item>
  13. <detail-list-item term="设备旧号">{{ model.zbh }}</detail-list-item>
  14. <detail-list-item term="型号">{{ model.model }}</detail-list-item>
  15. <detail-list-item term="设备名称">{{ model.name }}</detail-list-item>
  16. </detail-list>
  17. <title-divider title="保养信息" width="90px"></title-divider>
  18. <div class="table-operator" style="margin-bottom:8px;">
  19. <a-button type="primary" @click="handleAdd">
  20. <a-icon type="plus"/>
  21. 添加
  22. </a-button>
  23. <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
  24. <a-icon type="plus"/>
  25. 复制
  26. </a-button>
  27. <a-button style="margin-left:8px;" type="primary" @click="doImport">
  28. <a-icon type="upload"/>
  29. 新增导入
  30. </a-button>
  31. <!-- <a-button style="margin-left: 8px" type="primary" icon="download" @click="doExport">导出</a-button>-->
  32. </div>
  33. <a-table
  34. :data-source="data"
  35. :columns="columns"
  36. tableLayout="auto"
  37. rowKey="id">
  38. <span slot="action" slot-scope="record">
  39. <template>
  40. <a v-if="$auth('sb-infos-edit')" @click="handleView(record)">查看</a>
  41. <a-divider type="vertical" />
  42. <a v-if="$auth('sb-infos-edit')" @click="handleEdit(record)">修改</a>
  43. <a-divider type="vertical" />
  44. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  45. <a>删除</a>
  46. </a-popconfirm>
  47. <a-divider type="vertical" />
  48. <a @click="handleCopy(record)">复制</a>
  49. <a-divider type="vertical" />
  50. <a @click="handleGenerate(record)">插入任务</a>
  51. </template>
  52. </span>
  53. </a-table>
  54. <base-form ref="baseModal" :check-type="checkType" @ok="handleOk"/>
  55. <base-form-insert ref="baseModalInsert" @ok="handleOk"/>
  56. <detail ref="detailModal"/>
  57. <sb-info-select-modal :type="'radio'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
  58. <import-form-add ref="importModal" @ok="handleOk"/>
  59. </div>
  60. </template>
  61. <script>
  62. import DetailList from '@/components/tools/DetailList'
  63. import {
  64. queryCheckStandard,
  65. deleteCheckStandards,
  66. exportCheckStandard,
  67. fetchCheckStandard,
  68. copy
  69. } from '@/api/check/checkstandard'
  70. import BaseForm from './BaseForm'
  71. import BaseFormInsert from './BaseFormInsert'
  72. import Detail from './Detail'
  73. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  74. import ImportFormAdd from '@/views/check/checkstandard/modules/ImportFormAdd'
  75. const DetailListItem = DetailList.Item
  76. export default {
  77. name: 'DetailSbCheck',
  78. components: {
  79. DetailList,
  80. DetailListItem,
  81. BaseForm,
  82. Detail,
  83. SbInfoSelectModal,
  84. BaseFormInsert,
  85. ImportFormAdd
  86. },
  87. props: {
  88. /**
  89. * 检查类型: 1-点检 2-巡检
  90. */
  91. checkType: {
  92. type: Number,
  93. default: 2
  94. }
  95. },
  96. data () {
  97. return {
  98. confirmLoading: false,
  99. mdl: {},
  100. model: {
  101. 'id': null,
  102. 'modelId': null,
  103. 'no': null,
  104. 'zbh': null,
  105. 'name': null,
  106. 'nameModel': null,
  107. 'unit': null,
  108. 'level': null,
  109. 'useType': null
  110. },
  111. modalTitle: null,
  112. visible: false,
  113. typeMap: {},
  114. checkUserTypeMap: {},
  115. actionTypeMap: {},
  116. // 表头
  117. columns: [
  118. {
  119. title: '序号',
  120. dataIndex: 'index',
  121. customRender: (text, record, index) => {
  122. return index + 1
  123. }
  124. },
  125. {
  126. title: '检查部位',
  127. dataIndex: 'partName'
  128. },
  129. {
  130. title: '名称',
  131. dataIndex: 'name',
  132. width: '300px'
  133. },
  134. {
  135. title: '周期',
  136. dataIndex: 'periodType',
  137. customRender: (text, record, index) => {
  138. return record.period + this.BaseTool.Table.getMapText(this.periodTypeMap, text)
  139. }
  140. },
  141. /* {
  142. title: '动作类型',
  143. dataIndex: 'actionType',
  144. customRender: (text, record, index) => {
  145. return this.BaseTool.Table.getMapText(this.actionTypeMap, text)
  146. }
  147. },*/
  148. {
  149. title: '标准工时',
  150. dataIndex: 'standardHours'
  151. },
  152. {
  153. title: '操作',
  154. key: 'action',
  155. checked: true,
  156. align: 'center',
  157. // fixed: 'right',
  158. scopedSlots: { customRender: 'action' }
  159. }
  160. ],
  161. data: []
  162. }
  163. },
  164. created () {
  165. // 下拉框map
  166. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
  167. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  168. this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  169. this.checkUserTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_USER_TYPE)
  170. },
  171. methods: {
  172. base (record) {
  173. this.visible = true
  174. this.model = record
  175. this.modalTitle = '详情2'
  176. queryCheckStandard({ sbId: record.id, type: this.checkType }).then(res => {
  177. this.data = res.data
  178. })
  179. },
  180. handleOk () {
  181. queryCheckStandard({ sbId: this.model.id, type: this.checkType }).then(res => {
  182. this.data = res.data
  183. })
  184. },
  185. handleAdd () {
  186. const modal = this.$refs.baseModal
  187. modal.base(null, this.model.id, this.model.no)
  188. },
  189. handleView (record) {
  190. fetchCheckStandard({ id: record.id }).then(res => {
  191. const modal = this.$refs.detailModal
  192. res.data.partName = record.partName
  193. modal.base(res.data)
  194. })
  195. },
  196. handleEdit (record) {
  197. fetchCheckStandard({ id: record.id }).then(res => {
  198. const modal = this.$refs.baseModal
  199. res.data.sbNo = this.model.no
  200. modal.base(res.data, this.model.id)
  201. })
  202. },
  203. handleCopy (record) {
  204. const modal = this.$refs.baseModal
  205. const data = record
  206. data.id = null
  207. modal.base(data)
  208. },
  209. handleGenerate (record) {
  210. const modal = this.$refs.baseModalInsert
  211. modal.base(null, record.id)
  212. },
  213. handleCancel () {
  214. this.visible = false
  215. this.confirmLoading = false
  216. this.$emit('ok')
  217. },
  218. batchDelete (id) {
  219. let ids = []
  220. if (this.BaseTool.String.isBlank(id)) {
  221. if (length === 0) {
  222. this.$message.info('请选择要删除的记录')
  223. return
  224. }
  225. ids = this.selectedRows.map(item => item.id)
  226. } else {
  227. ids = [id]
  228. }
  229. deleteCheckStandards(ids).then(res => {
  230. this.$message.info('删除成功')
  231. this.handleOk()
  232. })
  233. },
  234. doExport () {
  235. const parameter = {
  236. ...this.queryParam
  237. }
  238. parameter.modelId = this.model.id
  239. exportCheckStandard(parameter).then(file => {
  240. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  241. })
  242. },
  243. doImport () {
  244. this.$refs.importModal.base(this.model.no)
  245. },
  246. handleSbSelect () {
  247. this.$refs.sbInfoSelectModal.base()
  248. },
  249. handleSbSelected (keys, rows) {
  250. const [ key ] = keys
  251. const [ row ] = rows
  252. // 日期处理
  253. copy({ sbId: this.model.id, copySbId: row.id })
  254. .then((response) => {
  255. this.$message.info(response.data)
  256. this.handleOk()
  257. }).catch(() => {
  258. this.confirmLoading = false
  259. })
  260. }
  261. }
  262. }
  263. </script>