declareElementsModal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div id="declareElementsModal">
  3. <a-modal
  4. title="报关要素"
  5. v-model="declareElementsModVis"
  6. :confirmLoading="confirmLoading"
  7. @cancel="handleCancel"
  8. width="80%"
  9. style="top:330px;left:100px;"
  10. >
  11. <!-- 主表信息 回显 -->
  12. <a-card :bordered="false">
  13. <div class="table-page-search-wrapper">
  14. <a-form-model layout="inline" ref="form" :model="declareElements">
  15. <a-row :gutter="24">
  16. <a-col :md="6" :sm="8" style="display: none;">
  17. <a-form-model-item label="ID" prop="id">
  18. {{ declareElements.id }}
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="8" style="display: none;">
  22. <a-form-model-item label="账套" prop="acSetNo">
  23. {{ declareElements.acSetNo }}
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="8" style="display: none;">
  27. <a-form-model-item label="款号" prop="itemNumber">
  28. {{ declareElements.itemNumber }}
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="6" :sm="8" style="display: none;">
  32. <a-form-model-item label="存货名称" prop="inventoryName">
  33. {{ declareElements.inventoryName }}
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="8" style="display: none;">
  37. <a-form-model-item label="发运明细子表ID" prop="syShippingids">
  38. {{ declareElements.itemIds }}
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="24" :sm="8" style="margin-bottom: 1%;" >
  42. <a-form-model-item label="物料名称" prop="declarationUnit" >
  43. <a-input placeholder="请输入物料名称" v-model="declareElements.inventoryName" readOnly ></a-input>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="8">
  47. <a-form-model-item label="报关品名" prop="declarationName" :rules="[{ required: true, message: '请输入报关品名!' }]">
  48. <!-- <a-input placeholder="请输入报关品名" v-model="declareElements.declarationName"></a-input> -->
  49. <a-select v-model="declareElements.declarationName" show-search :filterOption="filterOption">
  50. <a-select-option
  51. v-for="(item,index) in productNameOption"
  52. :key="index"
  53. :value="item.value">
  54. {{item.text}}
  55. </a-select-option>
  56. </a-select>
  57. </a-form-model-item>
  58. </a-col>
  59. <!-- <a-col :md="6" :sm="8">
  60. <a-form-model-item label="报关品名" prop="declarationName">
  61. {{ declareElements.declarationName }}
  62. </a-form-model-item>
  63. </a-col> -->
  64. <a-col :md="6" :sm="8">
  65. <a-form-model-item label="HSCODE" prop="hsCode" :rules="[{ required: true, message: '请输入HSCODE!' }]">
  66. <a-input placeholder="请输入HSCODE" v-model="declareElements.hsCode"></a-input>
  67. </a-form-model-item>
  68. </a-col>
  69. <!-- <a-col :md="6" :sm="8">
  70. <a-form-model-item label="HSCODE" prop="hsCode">
  71. {{ declareElements.hsCode }}
  72. </a-form-model-item>
  73. </a-col> -->
  74. <a-col :md="6" :sm="8">
  75. <a-form-model-item label="英文品名" prop="englishProductName" :rules="[{ required: true, message: '请输入英文品名!' }]">
  76. <a-input placeholder="请输入英文品名" v-model="declareElements.englishProductName" @blur="convertUppercase(declareElements.englishProductName)"></a-input>
  77. </a-form-model-item>
  78. </a-col>
  79. <a-col :md="6" :sm="8">
  80. <a-form-model-item label="报关单位" prop="declarationUnit" >
  81. <j-search-select-tag
  82. placeholder=""
  83. v-model="declareElements.declarationUnit"
  84. dict="declarationUnit">
  85. </j-search-select-tag>
  86. </a-form-model-item>
  87. </a-col>
  88. <!-- <a-col :md="6" :sm="8">
  89. <a-form-model-item label="英文品名" prop="englishProductName">
  90. {{ declareElements.englishProductName }}
  91. </a-form-model-item>
  92. </a-col> -->
  93. </a-row>
  94. </a-form-model>
  95. </div>
  96. </a-card>
  97. <!-- 増行 子表 -->
  98. <a-card :bordered="false" style="margin:10px 0">
  99. <a-button type="primary" @click="handleAddColumn" icon="plus" style="margin:10px 10px;">
  100. 増行
  101. </a-button>
  102. <a-button type="primary" @click="queryLatelyDeclarationElements" :disabled="query=='1'" icon="plus" style="margin:10px 0;">
  103. 查询
  104. </a-button>
  105. <!-- 子表 -->
  106. <a-spin :spinning="confirmLoading">
  107. <a-form-model ref="formRef">
  108. <a-table
  109. v-if="declareElementsData"
  110. bordered
  111. rowKey="id"
  112. :columns="declareElementsColumns"
  113. :data-source="declareElementsData"
  114. :loading="loading"
  115. :pagination="false"
  116. :scroll="{y: 500}"
  117. >
  118. <!-- 类型 下拉选择 -->
  119. <template slot="typeValueSlot" slot-scope="text, record, index">
  120. <a-form-model-item prop="typeValue">
  121. <a-select v-model="record.typeValue">
  122. <a-select-option
  123. v-for="(item,index) in arrOption"
  124. :key="index"
  125. :value="item.value">
  126. {{item.label}}
  127. </a-select-option>
  128. </a-select>
  129. <!-- <j-dict-select-tag v-model="record.typeValue" placeholder="请选择类型" style="text-align:left;"
  130. dictCode="sys_dict_item,item_text,item_text,dict_id='1536626597689970689'" :disabled="pushState">
  131. </j-dict-select-tag> -->
  132. </a-form-model-item>
  133. </template>
  134. <!-- 描述 输入框-->
  135. <template slot="describeText" slot-scope="text, record, index">
  136. <a-form-model-item prop="describeText">
  137. <a-input style="width:100%" type="text" v-model="record.describeText" :disabled="pushState"/>
  138. </a-form-model-item>
  139. </template>
  140. <template slot="state" slot-scope="text, record, index">
  141. <a-form-model-item prop="state">
  142. <a-input style="width:100%" type="text" v-model="state" />
  143. </a-form-model-item>
  144. </template>
  145. <!-- 操作 -->
  146. <span slot="operationSlot" slot-scope="text, record, index" >
  147. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(index)" v-if="!pushState">
  148. <a href="javascript:void(0);" style="color:red;">删除</a>
  149. </a-popconfirm>
  150. <a style="color:red;" v-if="pushState" @click="handleNotDelete">删除</a>
  151. </span>
  152. </a-table>
  153. </a-form-model>
  154. </a-spin>
  155. </a-card>
  156. <!-- 页面底部保存取消 -->
  157. <div
  158. :style="{
  159. position: 'absolute',
  160. right: 0,
  161. bottom: 0,
  162. width: '100%',
  163. borderTop: '1px solid #e9e9e9',
  164. padding: '10px 16px',
  165. background: '#fff',
  166. textAlign: 'right',
  167. zIndex: 1
  168. }"
  169. >
  170. <a-popconfirm title="确定放弃?" @confirm="handleCancel" okText="确定" cancelText="取消">
  171. <a-button :style="{ marginRight: '8px' }">返回</a-button>
  172. </a-popconfirm>
  173. <a-button type="primary" @click="addSave">
  174. 保存
  175. </a-button>
  176. </div>
  177. </a-modal>
  178. </div>
  179. </template>
  180. <script>
  181. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  182. import JEllipsis from '@/components/jeecg/JEllipsis'
  183. import moment from 'moment'
  184. import { syDeclarationElementsAdd,queryLatelyDeclarationElements } from '@api/document/shipmentList'
  185. import {Dictionaries} from '@api/document/book.js'
  186. export default {
  187. name: 'DeclareElementsModal', // 报关要素
  188. mixins: [JeecgListMixin],
  189. components: { JEllipsis, moment },
  190. data() {
  191. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  192. return {
  193. loading: false, // 表格加载
  194. pushState: false, //是否推送
  195. query:'1',//是否查询
  196. record:'',
  197. // 子表表头
  198. declareElementsColumns: [
  199. {
  200. title: '序号',
  201. width: 30,
  202. dataIndex: 'index',
  203. customRender: (text, record, index) => `${index + 1}`,
  204. className: 'replacecolor'
  205. },
  206. {
  207. title: '类型',
  208. dataIndex: 'typeValue',
  209. width: 250,
  210. scopedSlots: { customRender: 'typeValueSlot' },
  211. // customRender: t => ellipsis(t),
  212. },
  213. {
  214. title: '描述',
  215. dataIndex: 'describeText',
  216. width: 200,
  217. scopedSlots: { customRender: 'describeText' },
  218. className: 'replacecolor'
  219. },
  220. {
  221. title: '操作',
  222. dataIndex: 'operation',
  223. scopedSlots: { customRender: 'operationSlot' },
  224. width: 30,
  225. className: 'replacecolor'
  226. }
  227. ],
  228. declareElements: {}, // 主表信息
  229. declareElementsData: [], // 子表信息
  230. confirmLoading: false,
  231. declareElementsModVis: false,
  232. arrOption:[],
  233. flourOrGarment:"",
  234. orderNumber:'',
  235. productNameOption:[]
  236. }
  237. },
  238. // 接收父组件 方法
  239. props: {},
  240. created() {
  241. this.getOption()
  242. },
  243. methods: {
  244. //品名下拉框数据
  245. //获取类别数据字典
  246. getOption(){
  247. Dictionaries({code:'customs_declaration_elements'}).then(res => {
  248. this.arrOption = res
  249. })
  250. Dictionaries({code:'declaration_name'}).then(res=>{
  251. this.productNameOption = res
  252. })
  253. },
  254. //报关品名下拉框模糊搜索
  255. filterOption(input, option) {
  256. return (
  257. option.componentOptions.children[0].text
  258. .toLowerCase()
  259. .indexOf(input.toLowerCase()) >= 0
  260. )},
  261. //英文品名转化大写
  262. convertUppercase(val){
  263. this.declareElements.englishProductName = val.toUpperCase()
  264. },
  265. // 増行
  266. handleAddColumn() {
  267. console.log('増行')
  268. const addrow = {
  269. index: '',
  270. typeValue: '',
  271. describeText: '',
  272. operation: ''
  273. }
  274. this.declareElementsData.push(addrow)
  275. },
  276. //查询最近报关信息
  277. queryLatelyDeclarationElements(){
  278. var hscode = this.declareElements.declarationName;
  279. queryLatelyDeclarationElements({hscode:hscode,itemNumber:this.declareElements.itemNumber,orderNumber:this.orderNumber,pkOrg:this.declareElements.acSetNo}).then(res=>{
  280. if(res.success){
  281. res.result['itemIds'] = this.declareElements.itemIds;
  282. this.declareElements=res.result;
  283. this.declareElementsData=res.result.syDeclarationElementsItemList;
  284. //console.info("赋值数据:"+JSON.stringify(this.declareElements))
  285. }else{
  286. this.$message.error(res.message);
  287. }
  288. })
  289. },
  290. // 报关要素 保存
  291. addSave() {
  292. //表单验证
  293. this.$refs.form.validate(valid => {
  294. if (valid) {
  295. var type = [],
  296. sta = true
  297. this.declareElementsData.map(item => {
  298. type.push(item.typeValue)
  299. if(item.typeValue === '' ){
  300. sta = false
  301. }
  302. })
  303. var typeSet = [...new Set(type)]
  304. //类型/描述为空时
  305. if(!sta){
  306. this.$message.error("类型不可为空!");
  307. } else if(typeSet.length !== type.length){ //类名重复时
  308. this.$message.error("类型不能重复选择!");
  309. } else {
  310. var newObj = {} // 新增主表
  311. newObj.id = this.declareElements.id
  312. newObj.declarationName = this.declareElements.declarationName //报关品名
  313. newObj.declarationUnit = this.declareElements.declarationUnit //单位
  314. newObj.hsCode = this.declareElements.hsCode
  315. newObj.englishProductName = this.declareElements.englishProductName //英文品名
  316. newObj.acSetNo = this.declareElements.acSetNo //账套
  317. newObj.inventoryName = this.declareElements.inventoryName //物料名称
  318. newObj.itemNumber = this.declareElements.itemNumber //款号
  319. newObj.syShippingids = this.declareElements.itemIds//发运明细子表ID
  320. newObj.type = this.flourOrGarment
  321. newObj.code =this.orderNumber
  322. // 新增子表
  323. this.declareElementsData.map((item,index)=>{
  324. item.sort = index+1
  325. })
  326. newObj.syDeclarationElementsItemList = this.declareElementsData
  327. // newDeclareElement.documentNo = this.addShipDet.documentNo // 单据号
  328. syDeclarationElementsAdd(newObj).then(res => {
  329. if (res.success) {
  330. this.$message.success('新增成功')
  331. this.$emit('close-data',newObj,this.record)
  332. this.$emit('save-information',newObj.syDeclarationElementsItemList)
  333. // this.$emit('table')
  334. this.close()
  335. }else {
  336. this.$message.error(res.message)
  337. }
  338. })
  339. this.close()
  340. // 刷新
  341. }
  342. }
  343. })
  344. },
  345. handletypeValue(e) {
  346. console.log('类型下拉菜单click', e)
  347. },
  348. // 操作 删除
  349. handleDelete(index) {
  350. console.log('index', index)
  351. console.log('删除报关要素数据', index)
  352. if(this.declareElementsData.length === 1){
  353. this.$message.error("明细至少有一行!");
  354. }else {
  355. return this.declareElementsData.splice(index, 1)
  356. }
  357. },
  358. //已推送的情况下删除
  359. handleNotDelete(){
  360. this.$message.error("不可删除!");
  361. },
  362. close() {
  363. this.$emit('close-declare')
  364. this.declareElementsModVis = false
  365. this.declareElements = {}
  366. this.declareElementsData = []
  367. this.pushState = false
  368. // console.log('清空')
  369. },
  370. handleCancel() {
  371. this.close()
  372. },
  373. handleTableChange() {
  374. console.log('??这是啥')
  375. }
  376. },
  377. computed: {}
  378. }
  379. </script>
  380. <style lang="less" scoped>
  381. @import '~@assets/less/common.less';
  382. @import '~@assets/less/overwriter.less';
  383. /deep/ .ant-table-thead > tr > th {
  384. text-align: center;
  385. // font-weight: 700;
  386. }
  387. /deep/ .ant-table-tbody {
  388. text-align: center;
  389. }
  390. // th.replacecolor {
  391. // background-color: #ccc;
  392. // }
  393. // 对话框里的card样式
  394. /deep/ .ant-modal-content {
  395. background-color: #f0f2f5;
  396. }
  397. /deep/ .ant-modal-body {
  398. padding: 10px;
  399. }
  400. /deep/.ant-form-item{
  401. margin-bottom: 0px !important;
  402. }
  403. /deep/.ant-table-tbody .ant-table-row td{
  404. padding-top: 2px;
  405. padding-bottom: 2px;
  406. }
  407. /deep/ thead.ant-table-thead>tr{
  408. height: 0 !important;
  409. }
  410. /deep/ .ant-table-thead > tr > th, .ant-table-tbody > tr > td{
  411. padding: 9px 16px
  412. }
  413. </style>