addInvoiceDialog.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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 clearable v-model="form.linkName" placeholder="请输入" />
  41. </el-form-item>
  42. <el-form-item prop="sendFiles" label="发货附件">
  43. <fileUpload
  44. v-model="form.sendFiles"
  45. module="main"
  46. :showLib="false"
  47. :limit="10"
  48. />
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="12">
  52. <el-form-item label="车辆号" prop="carNo" style="margin-bottom: 22px">
  53. <el-input clearable v-model="form.carNo" placeholder="请输入" />
  54. </el-form-item>
  55. <!-- <el-form-item
  56. label="订单编码"
  57. prop="orderNo"
  58. style="margin-bottom: 22px"
  59. >
  60. <span>{{form.orderNo}}</span>
  61. </el-form-item> -->
  62. <el-form-item
  63. label="客户电话"
  64. prop="linkPhone"
  65. style="margin-bottom: 22px"
  66. >
  67. <el-input clearable v-model="form.linkPhone" placeholder="请输入" />
  68. </el-form-item>
  69. <el-form-item
  70. label="收货地址"
  71. prop="receiveAddress"
  72. style="margin-bottom: 22px"
  73. >
  74. <el-input
  75. clearable
  76. v-model="form.receiveAddress"
  77. placeholder="请输入"
  78. />
  79. </el-form-item>
  80. <el-form-item prop="repliedFiles" label="回执附件">
  81. <fileUpload
  82. v-model="form.repliedFiles"
  83. module="main"
  84. :showLib="false"
  85. :limit="10"
  86. />
  87. </el-form-item>
  88. </el-col>
  89. </el-row>
  90. </el-form>
  91. <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle>
  92. <inventoryTable
  93. ref="inventoryTableref"
  94. :orderId="form.orderId"
  95. ></inventoryTable>
  96. <div slot="footer" class="footer">
  97. <el-button type="primary" @click="save">保存</el-button>
  98. <el-button type="primary" @click="save('sub')">提交</el-button>
  99. <el-button @click="cancel">返回</el-button>
  100. </div>
  101. <orderListDialog
  102. ref="orderListDialogRef"
  103. @changeParent="changeOrder"
  104. ></orderListDialog>
  105. </ele-modal>
  106. </template>
  107. <script>
  108. import { acceptUnpackoptions } from '@/enum/dict';
  109. import fileUpload from '@/components/upload/fileUpload';
  110. import dictMixins from '@/mixins/dictMixins';
  111. import parentList from '@/views/saleManage/contact/components/parentList.vue';
  112. import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
  113. import {
  114. addSendInformation,
  115. UpdateSendInformation,
  116. getSendSaleOrderrecordDetail,
  117. submit
  118. } from '@/api/saleManage/saleordersendrecord';
  119. import { getcontactlink } from '@/api/saleManage/businessFollow';
  120. import inventoryTable from './inventoryTable.vue';
  121. import orderListDialog from './orderListDialog.vue';
  122. import { copyObj } from '@/utils/util';
  123. export default {
  124. mixins: [dictMixins],
  125. components: {
  126. fileUpload,
  127. inventoryTable,
  128. orderListDialog,
  129. parentList
  130. },
  131. data() {
  132. let formDef = {
  133. id: '',
  134. contractId: '',
  135. sendFiles: [],
  136. repliedFiles: [],
  137. contractName: '',
  138. receiveAddress: '',
  139. carNo: '',
  140. carId: '',
  141. linkName: '',
  142. linkPhone: '',
  143. orderNo: '',
  144. orderId: '',
  145. replied: 0
  146. };
  147. return {
  148. detailData: {},
  149. payWayOptions: [],
  150. delDetailIds: [],
  151. linkNameOptions: [],
  152. acceptUnpackoptions,
  153. visible: false,
  154. title: '',
  155. row: {},
  156. activeName: 'base',
  157. formDef,
  158. form: copyObj(formDef),
  159. tableBankData: [],
  160. tableLinkData: [],
  161. // 组织机构树形结构数据
  162. groupTreeData: [],
  163. groupData: [],
  164. rules: {
  165. partaName: [
  166. { required: true, message: '请选择客户名称', trigger: 'change' }
  167. ]
  168. },
  169. // 提交状态
  170. loading: false,
  171. // 是否是修改
  172. isUpdate: false,
  173. businessId: ''
  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 {
  198. partaId,
  199. partaName,
  200. partaTel,
  201. orderNo,
  202. id,
  203. partaLinkName,
  204. receiveAddress,
  205. productList,
  206. totalAmount,
  207. payAmount
  208. } = data;
  209. if (productList && productList.length > 0) {
  210. productList.forEach((v) => {
  211. v.orderTotalCount = v.totalCount;
  212. });
  213. }
  214. this.form = Object.assign({}, this.form, {
  215. contactId: partaId,
  216. contactName: partaName,
  217. linkName: partaLinkName,
  218. linkPhone: partaTel,
  219. orderNo,
  220. orderId: id,
  221. receiveAddress,
  222. productList,
  223. totalAmount,
  224. payAmount
  225. });
  226. this.$refs.inventoryTableref &&
  227. this.$refs.inventoryTableref.putTableValue(productList);
  228. });
  229. }
  230. },
  231. //发货单详情
  232. async getSendSaleOrderDetail(id) {
  233. this.businessId = id;
  234. this.loading = true;
  235. const data = await getSendSaleOrderrecordDetail(id);
  236. this.loading = false;
  237. if (data) {
  238. this.$nextTick(() => {
  239. this.form = data;
  240. this.$refs.inventoryTableref &&
  241. this.$refs.inventoryTableref.putTableValue(data.productList);
  242. });
  243. }
  244. },
  245. //更新联系人数据
  246. async getLinkInfo(contactId) {
  247. const data = await getcontactlink({ contactId });
  248. if (data && data?.length) {
  249. this.linkNameOptions = data;
  250. }
  251. },
  252. selectFocus() {
  253. if (this.linkNameOptions.length === 0) {
  254. return this.$message.error('请先选择名称');
  255. }
  256. },
  257. handHead() {
  258. let item = {
  259. id: this.form.partbLinkId
  260. };
  261. this.$refs.headRef.open(item);
  262. },
  263. //选择订单弹框
  264. handleOrderBtn() {
  265. let item = {
  266. id: this.form.orderId
  267. };
  268. this.$refs.orderListDialogRef.open(item);
  269. },
  270. //打开新增编辑弹框
  271. async open(type, row, orderId) {
  272. this.title = type === 'add' ? '新增发货单' : '修改';
  273. this.row = row;
  274. this.visible = true;
  275. if (orderId) {
  276. this.getSaleOrderDetail(orderId);
  277. }
  278. if (row && row?.id) {
  279. this.getSendSaleOrderDetail(row?.id);
  280. }
  281. if (type == 'add') {
  282. this.isUpdate = false;
  283. } else {
  284. this.isUpdate = true;
  285. }
  286. },
  287. salesmanChange(val, info) {
  288. this.otherForm.salesmanName = info.name;
  289. },
  290. settlementModeChange(info) {
  291. this.form.settlementModeName = info.dictValue;
  292. },
  293. ifChiefChange(value, idx) {
  294. if (value === 1) {
  295. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  296. this.tableLinkData[idx].ifChief = 1;
  297. }
  298. },
  299. getValidate() {
  300. return Promise.all([
  301. new Promise((resolve, reject) => {
  302. this.$refs.form.validate((valid) => {
  303. if (!valid) {
  304. reject(false);
  305. } else {
  306. resolve(true);
  307. }
  308. });
  309. }),
  310. new Promise((resolve, reject) => {
  311. this.$refs.inventoryTableref.validateForm((valid) => {
  312. if (!valid) {
  313. reject(false);
  314. } else {
  315. resolve(true);
  316. }
  317. });
  318. })
  319. ]);
  320. },
  321. async save(type) {
  322. try {
  323. await this.getValidate();
  324. // 表单验证通过,执行保存操作
  325. this.loading = true;
  326. if (!this.isUpdate) {
  327. delete this.form.id;
  328. }
  329. this.form.repliedFiles = this.form.repliedFiles || [];
  330. this.form.replied = this.form.repliedFiles.length > 0 ? 1 : 0;
  331. let commitData = Object.assign({}, this.form, {
  332. productList: this.$refs.inventoryTableref.getTableValue()
  333. });
  334. if (this.isUpdate) {
  335. UpdateSendInformation(commitData)
  336. .then((res) => {
  337. this.loading = false;
  338. this.$message.success('修改成功');
  339. if (type === 'sub') {
  340. this.sendSubmit(res);
  341. return;
  342. }
  343. this.cancel();
  344. this.$emit('done');
  345. })
  346. .catch((e) => {
  347. //this.loading = false;
  348. });
  349. } else {
  350. addSendInformation(commitData)
  351. .then((res) => {
  352. this.loading = false;
  353. this.$message.success('新增成功');
  354. if (type === 'sub') {
  355. this.sendSubmit(res);
  356. return;
  357. }
  358. this.cancel();
  359. this.$emit('done');
  360. })
  361. .catch((e) => {
  362. //this.loading = false;
  363. });
  364. }
  365. } catch (error) {
  366. console.log(error);
  367. // 表单验证未通过,不执行保存操作
  368. }
  369. },
  370. sendSubmit(res) {
  371. submit({
  372. businessId: this.businessId || res
  373. // productionSupervisorId
  374. }).then((res) => {
  375. this.cancel();
  376. this.$emit('done');
  377. });
  378. },
  379. cancel() {
  380. this.$nextTick(() => {
  381. this.activeName = 'base';
  382. // 关闭后,销毁所有的表单数据
  383. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  384. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  385. this.$store.commit('order/clearUserData');
  386. this.form = copyObj(this.formDef);
  387. this.visible = false;
  388. });
  389. }
  390. }
  391. };
  392. </script>
  393. <style scoped lang="scss">
  394. .TotalAmount {
  395. font-size: 16px;
  396. padding-right: 30px;
  397. }
  398. .headbox {
  399. display: flex;
  400. justify-content: flex-start;
  401. align-items: center;
  402. .amount {
  403. font-size: 14px;
  404. font-weight: bold;
  405. margin-right: 20px;
  406. }
  407. }
  408. </style>