declareElementsModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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="6" :sm="8">
  42. <a-form-model-item label="报关品名" prop="declarationName" :rules="[{ required: true, message: '请输入报关品名!' }]">
  43. <a-input placeholder="请输入报关品名" v-model="declareElements.declarationName"></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">
  48. {{ declareElements.declarationName }}
  49. </a-form-model-item>
  50. </a-col> -->
  51. <a-col :md="6" :sm="8">
  52. <a-form-model-item label="HSCODE" prop="hsCode" :rules="[{ required: true, message: '请输入HSCODE!' }]">
  53. <a-input placeholder="请输入HSCODE" v-model="declareElements.hsCode"></a-input>
  54. </a-form-model-item>
  55. </a-col>
  56. <!-- <a-col :md="6" :sm="8">
  57. <a-form-model-item label="HSCODE" prop="hsCode">
  58. {{ declareElements.hsCode }}
  59. </a-form-model-item>
  60. </a-col> -->
  61. <a-col :md="6" :sm="8">
  62. <a-form-model-item label="英文品名" prop="englishProductName" :rules="[{ required: true, message: '请输入英文品名!' }]">
  63. <a-input placeholder="请输入英文品名" v-model="declareElements.englishProductName" @blur="convertUppercase(declareElements.englishProductName)"></a-input>
  64. </a-form-model-item>
  65. </a-col>
  66. <!-- <a-col :md="6" :sm="8">
  67. <a-form-model-item label="英文品名" prop="englishProductName">
  68. {{ declareElements.englishProductName }}
  69. </a-form-model-item>
  70. </a-col> -->
  71. </a-row>
  72. </a-form-model>
  73. </div>
  74. </a-card>
  75. <!-- 増行 子表 -->
  76. <a-card :bordered="false" style="margin:10px 0">
  77. <a-button type="primary" @click="handleAddColumn" icon="plus" style="margin:10px 0;">
  78. 増行
  79. </a-button>
  80. <!-- 子表 -->
  81. <a-spin :spinning="confirmLoading">
  82. <a-form-model ref="formRef">
  83. <a-table
  84. v-if="declareElementsData"
  85. bordered
  86. rowKey="id"
  87. :columns="declareElementsColumns"
  88. :data-source="declareElementsData"
  89. :loading="loading"
  90. :pagination="false"
  91. >
  92. <!-- 类型 下拉选择 -->
  93. <template slot="typeValueSlot" slot-scope="text, record, index">
  94. <a-form-model-item prop="typeValue">
  95. <j-dict-select-tag v-model="record.typeValue" placeholder="请选择类型" style="text-align:left;"
  96. dictCode="sys_dict_item,item_text,item_text,dict_id='1536626597689970689'" :disabled="pushState">
  97. </j-dict-select-tag>
  98. </a-form-model-item>
  99. </template>
  100. <!-- 描述 输入框-->
  101. <template slot="describeText" slot-scope="text, record, index">
  102. <a-form-model-item prop="describeText">
  103. <a-input style="width:100%" type="text" v-model="record.describeText" :disabled="pushState"/>
  104. </a-form-model-item>
  105. </template>
  106. <template slot="state" slot-scope="text, record, index">
  107. <a-form-model-item prop="state">
  108. <a-input style="width:100%" type="text" v-model="state" />
  109. </a-form-model-item>
  110. </template>
  111. <!-- 操作 -->
  112. <span slot="operationSlot" slot-scope="text, record, index" >
  113. <a-popconfirm title="确定删除吗?" ok-text="是" cancel-text="否" @confirm="handleDelete(index)" v-if="!pushState">
  114. <a href="javascript:void(0);" style="color:red;">删除</a>
  115. </a-popconfirm>
  116. <a style="color:red;" v-if="pushState" @click="handleNotDelete">删除</a>
  117. </span>
  118. </a-table>
  119. </a-form-model>
  120. </a-spin>
  121. </a-card>
  122. <!-- 页面底部保存取消 -->
  123. <div
  124. :style="{
  125. position: 'absolute',
  126. right: 0,
  127. bottom: 0,
  128. width: '100%',
  129. borderTop: '1px solid #e9e9e9',
  130. padding: '10px 16px',
  131. background: '#fff',
  132. textAlign: 'right',
  133. zIndex: 1
  134. }"
  135. >
  136. <a-popconfirm title="确定放弃?" @confirm="handleCancel" okText="确定" cancelText="取消">
  137. <a-button :style="{ marginRight: '8px' }">返回</a-button>
  138. </a-popconfirm>
  139. <a-button type="primary" @click="addSave">
  140. 保存
  141. </a-button>
  142. </div>
  143. </a-modal>
  144. </div>
  145. </template>
  146. <script>
  147. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  148. import JEllipsis from '@/components/jeecg/JEllipsis'
  149. import moment from 'moment'
  150. import { syDeclarationElementsAdd } from '@api/document/shipmentList'
  151. export default {
  152. name: 'DeclareElementsModal', // 报关要素
  153. mixins: [JeecgListMixin],
  154. components: { JEllipsis, moment },
  155. data() {
  156. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  157. return {
  158. loading: false, // 表格加载
  159. pushState: false, //是否推送
  160. // 子表表头
  161. declareElementsColumns: [
  162. {
  163. title: '序号',
  164. width: 30,
  165. dataIndex: 'index',
  166. customRender: (text, record, index) => `${index + 1}`,
  167. className: 'replacecolor'
  168. },
  169. {
  170. title: '类型',
  171. dataIndex: 'typeValue',
  172. width: 250,
  173. scopedSlots: { customRender: 'typeValueSlot' },
  174. // customRender: t => ellipsis(t),
  175. },
  176. {
  177. title: '描述',
  178. dataIndex: 'describeText',
  179. width: 200,
  180. scopedSlots: { customRender: 'describeText' },
  181. className: 'replacecolor'
  182. },
  183. {
  184. title: '操作',
  185. dataIndex: 'operation',
  186. scopedSlots: { customRender: 'operationSlot' },
  187. width: 30,
  188. className: 'replacecolor'
  189. }
  190. ],
  191. declareElements: {}, // 主表信息
  192. declareElementsData: [], // 子表信息
  193. confirmLoading: false,
  194. declareElementsModVis: false
  195. }
  196. },
  197. // 接收父组件 方法
  198. props: {},
  199. created() { },
  200. methods: {
  201. //英文品名转化大写
  202. convertUppercase(val){
  203. this.declareElements.englishProductName = val.toUpperCase()
  204. },
  205. // 増行
  206. handleAddColumn() {
  207. console.log('増行')
  208. const addrow = {
  209. index: '',
  210. typeValue: '',
  211. describeText: '',
  212. operation: ''
  213. }
  214. this.declareElementsData.push(addrow)
  215. },
  216. // 报关要素 保存
  217. addSave() {
  218. //表单验证
  219. this.$refs.form.validate(valid => {
  220. if (valid) {
  221. var type = [],
  222. sta = true
  223. this.declareElementsData.map(item => {
  224. type.push(item.typeValue)
  225. if(item.typeValue === '' ){
  226. sta = false
  227. }
  228. })
  229. var typeSet = [...new Set(type)]
  230. //类型/描述为空时
  231. if(!sta){
  232. this.$message.error("类型不可为空!");
  233. } else if(typeSet.length !== type.length){ //类名重复时
  234. this.$message.error("类型不能重复选择!");
  235. } else {
  236. var newObj = {} // 新增主表
  237. newObj.id = this.declareElements.id
  238. newObj.declarationName = this.declareElements.declarationName //报关品名
  239. newObj.hsCode = this.declareElements.hsCode
  240. newObj.englishProductName = this.declareElements.englishProductName //英文品名
  241. newObj.acSetNo = this.declareElements.acSetNo //账套
  242. newObj.inventoryName = this.declareElements.inventoryName //物料名称
  243. newObj.itemNumber = this.declareElements.itemNumber //款号
  244. newObj.syShippingids = this.declareElements.itemIds//发运明细子表ID
  245. // 新增子表
  246. newObj.syDeclarationElementsItemList = this.declareElementsData
  247. // newDeclareElement.documentNo = this.addShipDet.documentNo // 单据号
  248. syDeclarationElementsAdd(newObj).then(res => {
  249. if (res.success) {
  250. this.$message.success('新增成功')
  251. this.$emit('table')
  252. this.close()
  253. }else {
  254. this.$message.error(res.message)
  255. }
  256. })
  257. this.close()
  258. // 刷新
  259. }
  260. }
  261. })
  262. },
  263. handletypeValue(e) {
  264. console.log('类型下拉菜单click', e)
  265. },
  266. // 操作 删除
  267. handleDelete(index) {
  268. console.log('index', index)
  269. console.log('删除报关要素数据', index)
  270. if(this.declareElementsData.length === 1){
  271. this.$message.error("明细至少有一行!");
  272. }else {
  273. return this.declareElementsData.splice(index, 1)
  274. }
  275. },
  276. //已推送的情况下删除
  277. handleNotDelete(){
  278. this.$message.error("不可删除!");
  279. },
  280. close() {
  281. this.$emit('close-declare')
  282. this.declareElementsModVis = false
  283. this.declareElements = {}
  284. this.declareElementsData = []
  285. // console.log('清空')
  286. },
  287. handleCancel() {
  288. this.close()
  289. },
  290. handleTableChange() {
  291. console.log('??这是啥')
  292. }
  293. },
  294. computed: {}
  295. }
  296. </script>
  297. <style lang="less" scoped>
  298. @import '~@assets/less/common.less';
  299. @import '~@assets/less/overwriter.less';
  300. /deep/ .ant-table-thead > tr > th {
  301. text-align: center;
  302. // font-weight: 700;
  303. }
  304. /deep/ .ant-table-tbody {
  305. text-align: center;
  306. }
  307. // th.replacecolor {
  308. // background-color: #ccc;
  309. // }
  310. // 对话框里的card样式
  311. /deep/ .ant-modal-content {
  312. background-color: #f0f2f5;
  313. }
  314. /deep/ .ant-modal-body {
  315. padding: 10px;
  316. }
  317. </style>