MaterialRegistration.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <a-card :bordered="false" >
  3. <!-- 查询 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :md="6" :sm="12">
  8. <a-form-item label="设备名称">
  9. <a-input placeholder="输入设备名称查询" v-model="queryParam.name"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="12">
  13. <a-form-item label="购买日期">
  14. <a-date-picker
  15. style="width: 100%"
  16. placeholder="请选择购买日期"
  17. v-model="buyTime"
  18. @change="onEndDateChange"
  19. />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="12">
  23. <a-form-item label="状态">
  24. <a-input placeholder="输入设备状态查询" v-model="queryParam.type"></a-input>
  25. </a-form-item>
  26. </a-col>
  27. <template v-if="toggleSearchStatus">
  28. <a-col :md="6" :sm="12">
  29. <a-form-item label="编号">
  30. <a-input placeholder="输入编号查询" v-model="queryParam.code"></a-input>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="8">
  35. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  36. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  37. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  38. <a @click="handleToggleSearch" style="margin-left: 8px">
  39. {{ toggleSearchStatus ? '收起' : '展开' }}
  40. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  41. </a>
  42. </span>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <!-- 操作按钮区域 -->
  48. <div class="table-operator" style="border-top: 5px">
  49. <a-button type="primary" icon="download" @click="handleExportXls('物质登记单')">导出</a-button>
  50. <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>
  51. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete()">
  52. <a-button type="primary" icon="plus">删除</a-button>
  53. </a-popconfirm>
  54. </div>
  55. <!-- table区域-begin -->
  56. <div>
  57. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  58. <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  59. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  60. </div>
  61. <a-table
  62. ref="table"
  63. bordered
  64. size="middle"
  65. rowKey="id"
  66. :columns="columns"
  67. :dataSource="dataSource"
  68. :pagination="pagination"
  69. :scroll="{x: 1500 , y: 500 }"
  70. :loading="loading"
  71. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  72. @change="handleTableChange">
  73. <span slot="operation" slot-scope="text, record">
  74. <a @click="handleEdit(record)">编辑</a>
  75. <a-divider type="vertical" />
  76. <a @click="handleDetail(record)">详情</a>
  77. </span>
  78. </a-table>
  79. </div>
  80. <!-- 新增框 -->
  81. <add-material-registration ref='AddMaterialRegistration' @close="handleCl"></add-material-registration>
  82. <detail-material-registration ref="DetailMaterialRegistration"></detail-material-registration>
  83. </a-card>
  84. </template>
  85. <script>
  86. import { downFile } from '@/api/manage'
  87. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  88. import AddMaterialRegistration from './modules/AddMaterialRegistration'
  89. import DetailMaterialRegistration from './modules/DetailMaterialRegistration'
  90. import JEllipsis from '@/components/jeecg/JEllipsis'
  91. import {
  92. managementList,
  93. managementAdd,
  94. managementEdit,
  95. enterpriseEDelete,
  96. managementListA,
  97. managementListB,
  98. managementListC
  99. } from '@api/oa/cd-material-registration'
  100. import moment from 'moment'
  101. export default {
  102. name: "MaterialRegistration",
  103. mixins: [JeecgListMixin],
  104. components: {
  105. AddMaterialRegistration,
  106. DetailMaterialRegistration,
  107. moment,
  108. JEllipsis
  109. },
  110. data() {
  111. let ellipsis = (v, l = 10) => <j-ellipsis value={v} length={l} />
  112. return {
  113. queryParam:{ //查询条件
  114. },
  115. buyTime:'',
  116. selectedRowKeysL:[],
  117. // 表头
  118. columns:[
  119. {
  120. title: '编号',
  121. align: "center",
  122. dataIndex: 'code',
  123. width: 120
  124. },
  125. {
  126. title: '设备名称',
  127. align: "center",
  128. dataIndex: 'name',
  129. width: 120
  130. },
  131. {
  132. title: '型号',
  133. align: "center",
  134. dataIndex: 'model',
  135. width: 120
  136. },
  137. {
  138. title: '购买日期',
  139. align: "center",
  140. dataIndex: 'buyTime',
  141. width: 120
  142. },
  143. {
  144. title: '购买数量',
  145. align: "center",
  146. dataIndex: 'buyNum',
  147. width: 120
  148. },
  149. {
  150. title: '单位',
  151. align: "center",
  152. dataIndex: 'unit',
  153. width: 120
  154. },
  155. {
  156. title: '购买金额',
  157. align: "center",
  158. dataIndex: 'amount',
  159. width: 120
  160. },
  161. {
  162. title: '使用者',
  163. align: "center",
  164. dataIndex: 'useId',
  165. width: 120
  166. },
  167. {
  168. title: '状态',
  169. align: "center",
  170. dataIndex: 'type',
  171. width: 120
  172. },
  173. {
  174. title: '供货方',
  175. align: "center",
  176. dataIndex: 'supply',
  177. width: 120
  178. },
  179. {
  180. title: '备注',
  181. align: "center",
  182. dataIndex: 'remarks',
  183. width: 120,
  184. customRender: (t) => ellipsis(t),
  185. },
  186. {
  187. title: '来源',
  188. align: "center",
  189. dataIndex: 'source',
  190. width: 120
  191. },
  192. {
  193. title: '操作',
  194. align: "center",
  195. dataIndex: 'operation',
  196. scopedSlots: { customRender: 'operation' },
  197. width: 120
  198. },
  199. ],
  200. pagination:{ }
  201. }
  202. },
  203. computed: {
  204. },
  205. created(){
  206. this.getData()
  207. },
  208. methods: {
  209. /* 导出 */
  210. handleExportXls(fileName){
  211. if(!fileName || typeof fileName != "string"){
  212. fileName = "导出文件"
  213. }
  214. let param = {...this.queryParam};
  215. if(this.selectedRowKeys && this.selectedRowKeys.length>0){
  216. param['selections'] = this.selectedRowKeys.join(",")
  217. }
  218. console.log("导出参数",param)
  219. downFile('/oa/syMaterial/exportXls',param).then((data)=>{
  220. if (!data) {
  221. this.$message.warning("文件下载失败")
  222. return
  223. }
  224. if (typeof window.navigator.msSaveBlob !== 'undefined') {
  225. window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
  226. }else{
  227. let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
  228. let link = document.createElement('a')
  229. link.style.display = 'none'
  230. link.href = url
  231. link.setAttribute('download', fileName+'.xls')
  232. document.body.appendChild(link)
  233. link.click()
  234. document.body.removeChild(link); //下载完成移除元素
  235. window.URL.revokeObjectURL(url); //释放掉blob对象
  236. }
  237. })
  238. },
  239. // 查询
  240. searchQuery(){
  241. this.getData()
  242. },
  243. //重置
  244. searchReset(){
  245. this.queryParam ={}
  246. this.buyTime = ''
  247. this.getData()
  248. },
  249. // 获取数据
  250. getData(){
  251. this.$nextTick(() => {
  252. managementList(this.queryParam).then(res => {
  253. // console.log('>>>>', this.queryParam)
  254. if (res.success) {
  255. this.dataSource =res.result.records
  256. this.pagination = {
  257. total: res.result.total,
  258. current: res.result.current,
  259. pageSize: res.result.size
  260. }
  261. }else{
  262. this.$message.error(res.message);
  263. }
  264. })
  265. })
  266. },
  267. onEndDateChange(value){
  268. this.queryParam.buyTime =moment(value).format('YYYY-MM-DD');
  269. },
  270. // 删除
  271. handleDelete(){
  272. if(this.selectedRowKeys.length == 0){
  273. this.$message.error("请选择要删除的数据");
  274. }else{
  275. var id = this.selectedRowKeys.toString()
  276. enterpriseEDelete({ids:id}).then(res => {
  277. // console.log('>>>>', this.queryParam)
  278. if (res.success) {
  279. this.$message.success('删除成功');
  280. this.getData()
  281. }else{
  282. this.$message.error(res.message);
  283. }
  284. })
  285. }
  286. },
  287. // 添加
  288. handleAdd(){
  289. this.$refs.AddMaterialRegistration.visible = true
  290. },
  291. //编辑
  292. async handleEdit(record){
  293. await managementListA({id:record.id}).then(res => {
  294. // console.log('>>>>', this.queryParam)
  295. if (res.success) {
  296. this.$refs.AddMaterialRegistration.formState = res.result
  297. this.$refs.AddMaterialRegistration.formState.buyTime = moment( res.result.buyTime)
  298. }else{
  299. this.$message.error(res.message);
  300. }
  301. })
  302. await managementListB({id:record.id}).then(res => {
  303. // console.log('>>>>', this.queryParam)
  304. if (res.success) {
  305. res.result.map(item =>[
  306. item.state = '0'
  307. ])
  308. this.$refs.AddMaterialRegistration.List = res.result
  309. }else{
  310. this.$message.error(res.message);
  311. }
  312. })
  313. await managementListC({id:record.id}).then(res => {
  314. // console.log('>>>>', this.queryParam)
  315. if (res.success) {
  316. res.result.map(item =>[
  317. item.state = '0'
  318. ])
  319. this.$refs.AddMaterialRegistration.List1 = res.result
  320. this.$refs.AddMaterialRegistration.visible = true
  321. this.$refs.AddMaterialRegistration.defult = 'edit'
  322. }else{
  323. this.$message.error(res.message);
  324. }
  325. })
  326. },
  327. //详情
  328. async handleDetail(record){
  329. await managementListA({id:record.id}).then(res => {
  330. // console.log('>>>>', this.queryParam)
  331. if (res.success) {
  332. this.$refs.DetailMaterialRegistration.formState = res.result
  333. }else{
  334. this.$message.error(res.message);
  335. }
  336. })
  337. await managementListB({id:record.id}).then(res => {
  338. // console.log('>>>>', this.queryParam)
  339. if (res.success) {
  340. this.$refs.DetailMaterialRegistration.List = res.result
  341. }else{
  342. this.$message.error(res.message);
  343. }
  344. })
  345. await managementListC({id:record.id}).then(res => {
  346. // console.log('>>>>', this.queryParam)
  347. if (res.success) {
  348. this.$refs.DetailMaterialRegistration.List1 = res.result
  349. this.$refs.DetailMaterialRegistration.visible = true
  350. this.$refs.DetailMaterialRegistration.visible = true
  351. }else{
  352. this.$message.error(res.message);
  353. }
  354. })
  355. },
  356. onSelectChange(keys,rows){
  357. this.selectedRowKeys = keys;
  358. this.selectedRows = rows;
  359. },
  360. // 分页变化时触发
  361. handleTableChange(pagination, filters, sorter) {
  362. this.queryParam.pageNo = pagination.current
  363. this.getData()
  364. },
  365. handleCl(){
  366. this.getData()
  367. }
  368. }
  369. }
  370. </script>
  371. <style scoped>
  372. @import '~@assets/less/common.less'
  373. </style>