addInvoiceDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. v-if="visible"
  6. :visible.sync="visible"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. width="80%"
  10. @close="cancel"
  11. >
  12. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  13. <headerTitle title="发货信息"></headerTitle>
  14. <el-row>
  15. <el-col :span="12">
  16. <el-form-item
  17. label="选择订单"
  18. prop="orderNo"
  19. style="margin-bottom: 22px"
  20. >
  21. <el-input
  22. clearable
  23. v-model="form.orderNo"
  24. @click.native="handleOrderBtn"
  25. placeholder="请输入"
  26. />
  27. </el-form-item>
  28. <el-form-item
  29. label="客户名称"
  30. prop="contactName"
  31. style="margin-bottom: 22px"
  32. >
  33. <span>{{form.contactName}}</span>
  34. </el-form-item>
  35. <el-form-item
  36. label="客户联系人"
  37. prop="linkName"
  38. style="margin-bottom: 22px"
  39. >
  40. <el-input
  41. clearable
  42. v-model="form.linkName"
  43. placeholder="请输入"
  44. />
  45. </el-form-item>
  46. <el-form-item prop="sendFiles" label="发货附件">
  47. <fileUpload
  48. v-model="form.sendFiles"
  49. module="main"
  50. :showLib="false"
  51. :limit="10"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="12">
  56. <el-form-item
  57. label="车辆号"
  58. prop="carNo"
  59. style="margin-bottom: 22px"
  60. >
  61. <el-input
  62. clearable
  63. v-model="form.carNo"
  64. placeholder="请输入"
  65. />
  66. </el-form-item>
  67. <!-- <el-form-item
  68. label="订单编码"
  69. prop="orderNo"
  70. style="margin-bottom: 22px"
  71. >
  72. <span>{{form.orderNo}}</span>
  73. </el-form-item> -->
  74. <el-form-item
  75. label="客户电话"
  76. prop="linkPhone"
  77. style="margin-bottom: 22px"
  78. >
  79. <el-input
  80. clearable
  81. v-model="form.linkPhone"
  82. placeholder="请输入"
  83. />
  84. </el-form-item>
  85. <el-form-item
  86. label="客户收货地址"
  87. prop="receiveAddress"
  88. style="margin-bottom: 22px"
  89. >
  90. <el-input
  91. clearable
  92. v-model="form.receiveAddress"
  93. placeholder="请输入"
  94. />
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. </el-form>
  99. <headerTitle title="产品清单" style="margin-top:30px;"></headerTitle>
  100. <inventoryTable ref="inventoryTableref" :orderId="form.orderId"></inventoryTable>
  101. <div slot="footer" class="footer">
  102. <el-button type="primary" @click="save">保存</el-button>
  103. <el-button @click="cancel">返回</el-button>
  104. </div>
  105. <orderListDialog ref="orderListDialogRef" @changeParent="changeOrder"></orderListDialog>
  106. </ele-modal>
  107. </template>
  108. <script>
  109. import { emailReg, phoneReg,numberReg } from 'ele-admin';
  110. import {acceptUnpackoptions} from '@/enum/dict';
  111. import fileUpload from '@/components/upload/fileUpload';
  112. import dictMixins from '@/mixins/dictMixins';
  113. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  114. import personSelect from '@/components/CommomSelect/person-select.vue';
  115. import parentList from '@/views/saleManage/contact/components/parentList.vue'
  116. import { getDetail} from '@/api/contractManage/contractBook';
  117. import { getSaleOrderDetail, UpdateInformation, addInformation,deleteInformation,updateStatus} from '@/api/saleManage/saleorder';
  118. import { addSendInformation,UpdateSendInformation,getSendSaleOrderrecordDetail} from '@/api/saleManage/saleordersendrecord';
  119. import {getcontactlink} from '@/api/saleManage/businessFollow';
  120. import inventoryTable from './inventoryTable.vue';
  121. import {listOrganizations} from '@/api/system/organization';
  122. import orderListDialog from './orderListDialog.vue';
  123. import {copyObj} from '@/utils/util';
  124. export default {
  125. mixins: [dictMixins],
  126. components: {
  127. fileUpload,
  128. deptSelect,
  129. inventoryTable,
  130. orderListDialog,
  131. parentList,
  132. personSelect
  133. },
  134. data() {
  135. let formDef = {
  136. id:'',
  137. contractId: '',
  138. sendFiles:[],
  139. contractName: '',
  140. receiveAddress:'',
  141. carNo:'',
  142. carId:'',
  143. linkName:'',
  144. linkPhone:'',
  145. orderNo:'',
  146. orderId:''
  147. };
  148. return {
  149. detailData:{},
  150. payWayOptions:[],
  151. delDetailIds:[],
  152. linkNameOptions:[],
  153. acceptUnpackoptions,
  154. visible: false,
  155. title: '',
  156. row: {},
  157. activeName: 'base',
  158. formDef,
  159. form: copyObj(formDef),
  160. tableBankData: [],
  161. tableLinkData: [],
  162. // 组织机构树形结构数据
  163. groupTreeData: [],
  164. groupData:[],
  165. rules: {
  166. partaName: [
  167. { required: true, message: '请选择客户名称', trigger: 'change' }
  168. ],
  169. },
  170. // 提交状态
  171. loading: false,
  172. // 是否是修改
  173. isUpdate: false,
  174. };
  175. },
  176. computed: {
  177. allcountAmount(){
  178. return this.$store.state.order.allcountAmount
  179. }
  180. },
  181. methods: {
  182. //选择订单回调
  183. changeOrder(obj){
  184. this.form = Object.assign({},this.form,{
  185. orderId: obj.id,
  186. orderNo: obj.orderNo,
  187. })
  188. this.getSaleOrderDetail(obj.id)
  189. },
  190. //获取订单详情
  191. async getSaleOrderDetail(id){
  192. this.loading = true;
  193. const data = await getSaleOrderDetail(id);
  194. this.loading = false;
  195. if (data) {
  196. this.$nextTick(()=>{
  197. let {partaId,partaName,partaTel,orderNo,id,partaLinkName,receiveAddress,productList,totalAmount,payAmount}=data
  198. if(productList&&productList.length>0){
  199. productList.forEach(v=>{
  200. v.orderTotalCount=v.totalCount
  201. })
  202. }
  203. this.form =Object.assign({}, this.form,{contactId:partaId,contactName:partaName,linkName:partaLinkName,linkPhone:partaTel,orderNo,orderId:id,receiveAddress,productList,totalAmount,payAmount}) ;
  204. this.$refs.inventoryTableref&&this.$refs.inventoryTableref.putTableValue(productList)
  205. })
  206. }
  207. },
  208. //发货单详情
  209. async getSendSaleOrderDetail(id){
  210. this.loading = true;
  211. const data = await getSendSaleOrderrecordDetail(id);
  212. this.loading = false;
  213. if (data) {
  214. this.$nextTick(()=>{
  215. this.form = data;
  216. this.$refs.inventoryTableref&&this.$refs.inventoryTableref.putTableValue(data.productList)
  217. })
  218. }
  219. },
  220. //更新联系人数据
  221. async getLinkInfo(contactId) {
  222. const data = await getcontactlink({contactId});
  223. if(data&&data?.length){
  224. this.linkNameOptions=data
  225. }
  226. },
  227. selectFocus(){
  228. if(this.linkNameOptions.length===0){
  229. return this.$message.error('请先选择名称')
  230. }
  231. },
  232. handHead(){
  233. let item={
  234. id:this.form.partbLinkId
  235. }
  236. this.$refs.headRef.open(item)
  237. },
  238. //选择订单弹框
  239. handleOrderBtn(){
  240. let item = {
  241. id: this.form.orderId
  242. }
  243. this.$refs.orderListDialogRef.open(item)
  244. },
  245. //打开新增编辑弹框
  246. async open(type, row,orderId) {
  247. this.title = type==='add'?'新增发货单':'修改';
  248. this.row = row;
  249. this.visible = true;
  250. if(orderId){
  251. this.getSaleOrderDetail(orderId)
  252. }
  253. if(row&&row?.id){
  254. this.getSendSaleOrderDetail(row?.id)
  255. }
  256. if (type == 'add') {
  257. this.isUpdate = false;
  258. } else {
  259. this.isUpdate = true;
  260. }
  261. },
  262. salesmanChange(val, info){
  263. this.otherForm.salesmanName = info.name;
  264. },
  265. settlementModeChange(info){
  266. this.form.settlementModeName = info.dictValue;
  267. },
  268. ifChiefChange(value, idx){
  269. if(value === 1){
  270. this.tableLinkData.forEach(e => e.ifChief = 0);
  271. this.tableLinkData[idx].ifChief = 1;
  272. }
  273. },
  274. getValidate() {
  275. return Promise.all([
  276. new Promise((resolve, reject) => {
  277. this.$refs.form.validate((valid) => {
  278. if (!valid) {
  279. reject(false);
  280. } else {
  281. resolve(true);
  282. }
  283. });
  284. })
  285. ]);
  286. },
  287. async save() {
  288. try {
  289. await this.getValidate();
  290. // 表单验证通过,执行保存操作
  291. this.loading = true;
  292. if (!this.isUpdate) {
  293. delete this.form.id;
  294. }
  295. let commitData=Object.assign({},this.form,{
  296. productList:this.$refs.inventoryTableref.getTableValue()
  297. })
  298. if (this.isUpdate) {
  299. UpdateSendInformation(commitData)
  300. .then((res) => {
  301. this.loading = false;
  302. this.$message.success("修改成功");
  303. this.cancel();
  304. this.$emit('done');
  305. })
  306. .catch((e) => {
  307. //this.loading = false;
  308. });
  309. } else {
  310. addSendInformation(commitData)
  311. .then((res) => {
  312. this.loading = false;
  313. this.$message.success("新增成功");
  314. this.cancel();
  315. this.$emit('done');
  316. })
  317. .catch((e) => {
  318. //this.loading = false;
  319. });
  320. }
  321. } catch (error) {
  322. console.log(error)
  323. // 表单验证未通过,不执行保存操作
  324. }
  325. },
  326. cancel() {
  327. this.$nextTick(() => {
  328. this.activeName = 'base';
  329. // 关闭后,销毁所有的表单数据
  330. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  331. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  332. this.$store.commit('order/clearUserData');
  333. this.form = copyObj(this.formDef)
  334. this.visible = false;
  335. })
  336. },
  337. }
  338. };
  339. </script>
  340. <style scoped lang="scss">
  341. .TotalAmount{
  342. font-size: 16px;
  343. padding-right: 30px;
  344. }
  345. .headbox{
  346. display: flex;
  347. justify-content: flex-start;
  348. align-items: center;
  349. .amount{
  350. font-size: 14px;
  351. font-weight: bold;
  352. margin-right: 20px;
  353. }
  354. }
  355. </style>