index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div class="search-history">
  3. <div class="headline">
  4. <span>申报要素维护</span>
  5. <div class="search_time">
  6. <el-input style="width:400px" placeholder="请输入品牌/型号/商品名称进行查询" v-model="key" @keyup.native.enter='searchSheet'>
  7. <el-button slot="append" @click.native="searchSheet">搜索</el-button>
  8. </el-input>
  9. <a @click="updateItem()"><i class="border_radius">+</i>新增</a>
  10. </div>
  11. </div>
  12. <ctable
  13. :headArr="headArr"
  14. :StyleWidth="StyleWidth"
  15. :data="tableData"
  16. :totalElements="totalElements"
  17. @handleCurrentChange="handleCurrentChange"
  18. :currentPage="currentPage"
  19. :controlArray="controlArray"
  20. @updateItem="updateItem"
  21. @lookItem="lookItem"
  22. :controlStyle="'height'"
  23. >
  24. </ctable>
  25. <element-alert :AlertTitle="AlertTitle"
  26. @closeAlert="closeAlert"
  27. :chooseItem="chooseItem"
  28. ref="elementAlert"
  29. :IslookOrUpdate="IslookOrUpdate">
  30. </element-alert>
  31. </div>
  32. </template>
  33. <script>
  34. import { clone, Vuehttp } from '@/utils/tools'
  35. import { CtableClass } from '@/utils/CtableClass'
  36. import { Ctable } from '@/components/base/table'
  37. import { elementAlert } from '@/components/severPage'
  38. export default {
  39. name: 'SearchElements',
  40. components: { Ctable, elementAlert },
  41. layout: 'default',
  42. middleware: 'authenticated',
  43. fetch({store}) {
  44. return Promise.all([
  45. store.dispatch('loadDeclarationElementsInfo', {count: 10, page: 1})
  46. ])
  47. },
  48. data () {
  49. return {
  50. hasDialog: false,
  51. key: '',
  52. currentPage: 1,
  53. count: 10,
  54. chooseItem: {},
  55. IslookOrUpdate: 'update'
  56. }
  57. },
  58. computed: {
  59. headArr() {
  60. return ['序号', '商品名称', '品牌', '规格型号', '海关编码', '申报要素', '规格书', '操作']
  61. },
  62. StyleWidth() {
  63. return [60, 150, 170, 234, 164, 240, 74, 72]
  64. },
  65. tableData() {
  66. // console.log(CtableClass(this.getHttpResource, ['序号', 'commodityName', 'brand', 'cmpCode', 'customerHouseCode', 'description', ['规格书', 'dataSheetUrl'], '操作']))
  67. return CtableClass(this.getHttpResource, ['序号', 'commodityName', 'brand', 'cmpCode', 'customerHouseCode', 'description', ['规格书', 'dataSheetUrl'], '操作'])
  68. },
  69. getHttpResource() {
  70. return this.$store.state.declarationElements.list.data.content.content
  71. },
  72. totalElements() {
  73. return this.$store.state.declarationElements.list.data.content.totalElements
  74. },
  75. controlArray() {
  76. return [['修改', 'updateItem'], ['查看', 'lookItem']]
  77. },
  78. AlertTitle() {
  79. return this.IslookOrUpdate === 'add' ? '新增申报要素' : (this.IslookOrUpdate === 'update' ? '修改申报要素' : '查看申报要素')
  80. }
  81. },
  82. methods: {
  83. updateItem(index) {
  84. this.chooseItem = {}
  85. this.IslookOrUpdate = 'add'
  86. if (index !== undefined) {
  87. this.IslookOrUpdate = 'update'
  88. this.chooseItem = clone(this.getHttpResource[index])
  89. }
  90. this.$refs.elementAlert.show()
  91. },
  92. lookItem(index) {
  93. this.IslookOrUpdate = 'look'
  94. this.chooseItem = clone(this.getHttpResource[index])
  95. this.$refs.elementAlert.show()
  96. },
  97. // 分页调整数据
  98. handleCurrentChange (page) {
  99. this.currentPage = page
  100. this.$store.dispatch('loadDeclarationElementsInfo', {count: this.count, page: this.currentPage, keyword: this.key})
  101. },
  102. // 修改数据内容
  103. // redactInfo (type) {
  104. // this.$router.push('/severPage/entrustApply/' + type.id)
  105. // },
  106. // 数据详情跳转
  107. // detailsInfo (type) {
  108. // this.$router.push('/severPage/elements/' + type.id)
  109. // },
  110. // 搜索内容
  111. searchSheet () {
  112. this.handleCurrentChange(1)
  113. },
  114. closeAlert(tp, item, file) {
  115. if (tp === 'save') {
  116. let params = {
  117. DeclarationElements: item,
  118. file: [file]
  119. }
  120. Vuehttp(params, '/facilitator/declarationElements/persist').then(res => {
  121. if (res.data.code !== 1) {
  122. this.$message.error(res.data.message)
  123. } else {
  124. this.handleCurrentChange(1)
  125. this.$refs.elementAlert.hide()
  126. }
  127. })
  128. } else {
  129. this.$refs.elementAlert.hide()
  130. }
  131. }
  132. // 新增加申报要素信息
  133. // submitForm (type) {
  134. // this.$refs[type].validate((valid) => {
  135. // if (!valid) {
  136. // this.$message({
  137. // message: '请正确填写信息',
  138. // type: 'warning'
  139. // })
  140. // return false
  141. // } else {
  142. // let params = new FormData()
  143. // params.append('params', JSON.stringify(this.form))
  144. // let config = {
  145. // headers: {'Content-Type': 'multipart/form-data'}
  146. // }
  147. // this.$http.post('/facilitator/declarationElements/persist', params, config)
  148. // .then(response => {
  149. // if (response.data.success) {
  150. // this.hasDialog = false
  151. // this.$message({
  152. // message: '保存成功',
  153. // type: 'success'
  154. // })
  155. // this.$store.dispatch('loadDeclarationElementsInfo', {count: this.count, page: 1})
  156. // } else {
  157. // this.$message({
  158. // message: response.data.message,
  159. // type: 'warning'
  160. // })
  161. // }
  162. // })
  163. // .catch(() => {
  164. // this.$message.error('请检查网络是否正常!')
  165. // })
  166. // }
  167. // })
  168. // }
  169. }
  170. }
  171. </script>
  172. <style type="text/scss" lang="scss">
  173. .search-history{
  174. /*padding:20px 10px;*/
  175. .search{
  176. margin-bottom:50px;
  177. position:relative;
  178. .el-input{
  179. max-width:50%;
  180. }
  181. .add{
  182. position:absolute;
  183. right:60px;
  184. }
  185. }
  186. }
  187. .block {
  188. padding-top:20px;
  189. text-align: right;
  190. }
  191. .dialog{
  192. .el-input{
  193. width:100%;
  194. }
  195. }
  196. .el-pagination {
  197. .el-pagination__jump .el-input{
  198. width: 60px !important;
  199. }
  200. }
  201. .el-input{
  202. .el-input-group__append{
  203. width:100px;
  204. color:#fff;
  205. background: #1890ff;
  206. text-align: center;
  207. }
  208. }
  209. .el-table{
  210. thead{
  211. color:#686c75;
  212. font-weight: bold;
  213. th{
  214. background: #f6f6f6;
  215. }
  216. }
  217. }
  218. </style>