tableInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="tableForm">
  4. <ele-pro-table
  5. ref="table"
  6. :needPage="false"
  7. :columns="columns"
  8. :datasource="tableForm.detailList"
  9. row-key="id"
  10. class="time-form"
  11. >
  12. <template v-slot:toolbar>
  13. <el-button type="text" @click="addRow">新增</el-button>
  14. <el-button type="text" @click="removeRow(scope.row)">选择商品</el-button>
  15. <el-button type="text" @click="removeRow(scope.row)">批量设置税率</el-button>
  16. <el-button type="text" @click="removeRow(scope.row)">批量设置单价</el-button>
  17. <el-button type="text" @click="removeRow(scope.row)">批量设置折让比例</el-button>
  18. </template>
  19. <template v-slot:totalCount="scope">
  20. <el-form-item
  21. style="width: 100%;"
  22. :prop="'detailList.' + scope.$index + '.totalCount'"
  23. :rules="[
  24. {
  25. required: true,
  26. message: '请输入数量',
  27. trigger: 'blur'
  28. },
  29. {
  30. validator: (rule, value, callback) => {
  31. if (value === undefined || value === null || value === '') {
  32. callback('请输入数量');
  33. } else if (parseFloat(value) <= 0) {
  34. callback('数量必须大于0');
  35. } else {
  36. callback();
  37. }
  38. },
  39. trigger: 'blur'
  40. }
  41. ]"
  42. >
  43. <span v-if="dialogType === 'view'">{{ scope.row.totalCount }}</span>
  44. <el-input v-else v-model="scope.row.totalCount" type="number" @input="updateTotalPrice(scope.row)"></el-input>
  45. </el-form-item>
  46. </template>
  47. </ele-pro-table>
  48. </el-form>
  49. </div>
  50. </template>
  51. <script>
  52. export default {
  53. name: 'tableInfo',
  54. components: {},
  55. props: {
  56. form: {
  57. type: Object,
  58. default: () => {
  59. return {
  60. detailList: []
  61. };
  62. }
  63. },
  64. dialogType: {
  65. type: String,
  66. default: ''
  67. },
  68. isOtherSourceFlag: {
  69. type: Boolean,
  70. default: false
  71. },
  72. contactData: {
  73. type: Object,
  74. default: () => {
  75. return {};
  76. }
  77. },
  78. invoiceAmount: {
  79. type: Number,
  80. default: 0
  81. }
  82. },
  83. data() {
  84. return {
  85. columns: [
  86. {
  87. width: 45,
  88. type: 'index',
  89. columnKey: 'index',
  90. align: 'center',
  91. fixed: 'left'
  92. },
  93. // {
  94. // width: 100,
  95. // prop: 'typeName',
  96. // label: '类型',
  97. // slot: 'typeName',
  98. // align: 'center'
  99. // },
  100. // {
  101. // minWidth: 100,
  102. // prop: 'sourceCode',
  103. // label: '类型编码',
  104. // slot: 'sourceCode',
  105. // align: 'center'
  106. // },
  107. // {
  108. // width: 100,
  109. // prop: 'productCategoryName',
  110. // label: '分类',
  111. // slot: 'productCategoryName',
  112. // align: "center"
  113. // },
  114. {
  115. width: 100,
  116. prop: 'productCode',
  117. label: '产品编码',
  118. align: "center"
  119. },
  120. {
  121. minWidth: 100,
  122. prop: 'productName',
  123. label: '产品名称',
  124. align: 'center'
  125. },
  126. {
  127. minWidth: 100,
  128. prop: 'batchNo',
  129. label: '批次号',
  130. align: 'center'
  131. },
  132. {
  133. minWidth: 100,
  134. prop: 'specification',
  135. label: '规格',
  136. align: 'center'
  137. },
  138. {
  139. minWidth: 100,
  140. prop: 'modelType',
  141. label: '型号',
  142. align: 'center'
  143. },
  144. {
  145. minWidth: 100,
  146. prop: 'colorKey',
  147. label: '颜色',
  148. align: 'center'
  149. },
  150. {
  151. width: 100,
  152. prop: 'totalCount',
  153. label: '数量',
  154. slot: 'totalCount',
  155. align: 'center',
  156. },
  157. {
  158. width: 100,
  159. prop: 'measuringUnit',
  160. label: '计量单位',
  161. slot: 'measuringUnit',
  162. align: 'center'
  163. },
  164. {
  165. width: 80,
  166. prop: 'singleWeight',
  167. label: '重量',
  168. align: 'center'
  169. },
  170. {
  171. width: 80,
  172. prop: 'singleWeight',
  173. label: '重量单位',
  174. align: 'center'
  175. },
  176. {
  177. width: 150,
  178. prop: 'pricingWay',
  179. label: '计价方式',
  180. formatter: (row, column) => {
  181. return row.pricingWay == 1
  182. ? '按数量计价'
  183. : row.pricingWay == 2
  184. ? '按重量计价'
  185. : '';
  186. },
  187. align: 'center'
  188. },
  189. {
  190. minWidth: 80,
  191. prop: 'singlePrice',
  192. label: '工艺路线',
  193. slot: 'singlePrice',
  194. align: 'center'
  195. },
  196. {
  197. minWidth: 80,
  198. prop: 'singlePrice',
  199. label: '单价',
  200. slot: 'singlePrice',
  201. align: 'center'
  202. },
  203. {
  204. minWidth: 80,
  205. prop: 'taxRate',
  206. slot: 'taxRate',
  207. label: '税率',
  208. align: 'center',
  209. formatter: (_row, _column, cellValue) => {
  210. return _row.taxRate
  211. ? _row.taxRate+'%'
  212. : '';
  213. },
  214. },
  215. {
  216. minWidth: 80,
  217. prop: 'singlePrice',
  218. label: '不含税单价',
  219. slot: 'singlePrice',
  220. align: 'center'
  221. },
  222. {
  223. minWidth: 80,
  224. prop: 'totalPrice',
  225. label: '合计',
  226. slot: 'totalPrice',
  227. align: 'center'
  228. },
  229. {
  230. minWidth: 80,
  231. prop: 'totalPrice',
  232. label: '折让比例',
  233. slot: 'totalPrice',
  234. align: 'center'
  235. },
  236. {
  237. minWidth: 80,
  238. prop: 'totalPrice',
  239. label: '折让单价',
  240. slot: 'totalPrice',
  241. align: 'center'
  242. },
  243. {
  244. minWidth: 80,
  245. prop: 'totalPrice',
  246. label: '折让合计',
  247. slot: 'totalPrice',
  248. align: 'center'
  249. },
  250. {
  251. minWidth: 80,
  252. prop: 'action',
  253. label: '操作',
  254. slot: 'action',
  255. align: 'center'
  256. },
  257. // {
  258. // width: 100,
  259. // prop: 'sourceType',
  260. // label: '来源类型',
  261. // slot: 'sourceType',
  262. // align: "center",
  263. // formatter: (row, column) => {
  264. // return row.sourceType == 2 ? '对账销售订单' : '对账采购订单';
  265. // }
  266. // },
  267. ],
  268. tableForm: {
  269. detailList: [],
  270. link: []
  271. },
  272. typeList: [
  273. {
  274. label: '销售发货',
  275. value: '10'
  276. },
  277. {
  278. label: '销售退货',
  279. value: '11'
  280. },
  281. {
  282. label: '采购收货',
  283. value: '20'
  284. },
  285. {
  286. label: '采购退货',
  287. value: '21'
  288. }
  289. ],
  290. };
  291. },
  292. mounted() {
  293. this.tableForm = this.form;
  294. },
  295. watch: {
  296. form(val) {
  297. this.tableForm = this.form;
  298. }
  299. },
  300. methods: {
  301. //获取选择的对账单数据
  302. async getAccountData(params) {
  303. if (params.children.orderType == 6) {
  304. this.tableForm.detailList = params.children.detailList;
  305. this.tableForm.detailList.forEach((item, index) => {
  306. item.sourceCode = params.children.orderNo;
  307. item.sourceId = params.children.id;
  308. item.sourceType = params.type == 1 ? 2 : 3;
  309. item.type = 12;
  310. item.singlePrice = item.discountSinglePrice;
  311. item.totalPrice = item.discountTotalPrice;
  312. item.typeName = '销售赔付';
  313. });
  314. } else {
  315. this.tableForm.detailList = [];
  316. params.children.subList.forEach((item, index) => {
  317. item.detailList.forEach((i, n) => {
  318. i.sourceCode = item.statementSubOrderCode;
  319. i.sourceId = params.children.id;
  320. i.sourceType = params.type == 1 ? 2 : 3;
  321. i.type = item.subType;
  322. console.log(item.subType);
  323. i.typeName = this.typeList.find(
  324. (i) => i.value == item.subType
  325. ).label;
  326. // i.singlePrice = item.discountSinglePrice
  327. i.totalPrice = i.discountTotalPrice;
  328. });
  329. this.tableForm.detailList.push(...item.detailList);
  330. });
  331. this.$refs.table.reload();
  332. }
  333. this.$emit(
  334. 'setPrice',
  335. params.children.amountTotalPrice - this.invoiceAmount
  336. );
  337. let row = {
  338. id: params.id,
  339. name: params.statementNo,
  340. code: params.statementNo,
  341. linkType: params.type == 1 ? 190 : 290,
  342. linkTypeName: params.type == 1 ? '销售对账单' : '采购对账单'
  343. };
  344. this.setSelectData(row);
  345. },
  346. setValue(data) {
  347. this.tableForm.detailList = data;
  348. },
  349. clearTable() {
  350. this.tableForm = {
  351. detailList: [],
  352. link: []
  353. };
  354. },
  355. // 当数量变化时更新金额
  356. updateTotalPrice(row) {
  357. if (row.totalCount && row.singlePrice) {
  358. row.totalPrice = (parseFloat(row.totalCount) * parseFloat(row.singlePrice)).toFixed(2);
  359. }
  360. },
  361. getTableValidate() {
  362. return new Promise((resolve, reject) => {
  363. if (
  364. this.tableForm.detailList.length == 0 &&
  365. ![4, 5].includes(this.form.sourceType)
  366. )
  367. return this.$message.warning('请选择关联信息');
  368. resolve(this.tableForm);
  369. });
  370. },
  371. validateForm(callback) {
  372. //开始表单校验
  373. this.$refs.form.validate((valid, obj) => {
  374. if (obj) {
  375. let messages = Object.keys(obj).map((key) => obj[key][0]);
  376. if (messages.length > 0) {
  377. this.$message.warning(messages[0].message);
  378. }
  379. }
  380. callback(valid);
  381. });
  382. },
  383. setSelectData(val) {
  384. this.tableForm.link = [{}];
  385. this.$set(this.tableForm.link[0], 'linkId', val.id);
  386. this.$set(this.tableForm.link[0], 'linkName', val.name);
  387. this.$set(this.tableForm.link[0], 'linkCode', val.code);
  388. this.$set(this.tableForm.link[0], 'linkType', val.linkType);
  389. this.$set(this.tableForm.link[0], 'linkTypeName', val.linkTypeName);
  390. },
  391. getTableData() {}
  392. }
  393. };
  394. </script>
  395. <style scoped lang="scss">
  396. .time-form .el-form-item {
  397. margin-bottom: 0 !important;
  398. }
  399. </style>