detailsPage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="goBack(0)">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <el-button class="el-button--small-yh" style="margin-left: 6px;" type="primary" size="small"
  11. @click="submit">保 存
  12. </el-button>
  13. </div>
  14. </div>
  15. <div style="margin-top: 50px">
  16. <trade-card title="基础信息">
  17. <avue-form :option="optionForm" v-model="form" ref="form">
  18. </avue-form>
  19. </trade-card>
  20. <trade-card title="仓储明细">
  21. <avue-crud :option="option" :data="form.storageFeeItemsList" id="out-table" ref="crud"
  22. @selection-change="selectionChange" @resetColumn="resetColumn('crud', 'option', 'optionBack', 409)"
  23. @saveColumn="saveColumn('crud', 'option', 'optionBack', 409)">
  24. <template slot="menuLeft">
  25. <el-button type="primary" size="small" icon="el-icon-plus" @click="addRow">新 增
  26. </el-button>
  27. </template>
  28. <tempalte slot="goodsTypeForm" slot-scope="{ row }">
  29. <dic-select v-if="row.$cellEdit" v-model="row.goodsType" placeholder="商品类型" key="dictKey"
  30. label="dictValue" url="/blade-system/dict-biz/dictionary?code=goods-type"
  31. :filterable="true"></dic-select>
  32. <span v-else>{{ row.goodsType }}</span>
  33. </tempalte>
  34. <!-- <template slot="feeName" slot-scope="{ row }">
  35. <dic-select v-if="row.$cellEdit" v-model="row.feeName" placeholder="费用信息" key="id" res="records"
  36. label="cnName" url="/blade-los/bfees/list" :filterable="true" :remote="true" fff
  37. dataName="cnName" @selectChange="rowDicChange('feeName', $event, row)"></dic-select>
  38. <span v-else>{{ row.feeName }}</span>
  39. </template> -->
  40. <template slot="menu" slot-scope="{ row, index }">
  41. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">{{ row.$cellEdit ?
  42. '保存' : '编辑' }}</el-button>
  43. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)">删除</el-button>
  44. </template>
  45. </avue-crud>
  46. </trade-card>
  47. <!-- <containerTitle title="上传附件"></containerTitle>
  48. <c-upload :data="form.filesCenterList" :enumerationValue="76"
  49. deleteUrl="/blade-purchase-sales/orderfiles/update" display :disabled="editDisabled"></c-upload> -->
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { submit, getDetail, copyAgent, itemRemove } from "@/api/iosBasicData/storageFee";
  55. import { getBtrademodesList, getBtrademodesDetail, addBtrademodes, updateBtrademodes, removeBtrademodes } from "@/api/iosBasicData/warehouse";
  56. import dicSelect from "@/components/dicSelect/main";
  57. import { bfeesList } from "@/api/iosBasicData/bfees";
  58. import _ from "lodash";
  59. export default {
  60. name: "detailsPage",
  61. data() {
  62. return {
  63. form: {
  64. status: '0',
  65. storageFeeItemsList: []
  66. },
  67. optionForm: {
  68. menuBtn: false,
  69. span: 8,
  70. column: [
  71. {
  72. label: "编码",
  73. prop: "code",
  74. disabled: false,
  75. rules: [{
  76. required: true,
  77. message: " ",
  78. trigger: "blur"
  79. }]
  80. },
  81. {
  82. label: "中文名称",
  83. prop: "cname",
  84. disabled: false,
  85. rules: [{
  86. required: true,
  87. message: " ",
  88. trigger: "blur"
  89. }]
  90. },
  91. {
  92. label: "状态",
  93. prop: "status",
  94. type: "select",
  95. search: true,
  96. dicData: [{
  97. label: '启用',
  98. value: '0'
  99. }, {
  100. label: '停用',
  101. value: '1'
  102. }],
  103. value: '0',
  104. overHidden: true,
  105. },
  106. {
  107. label: '备注',
  108. prop: "remarks",
  109. type: 'textarea',
  110. disabled: false,
  111. minRows: 2,
  112. },
  113. ]
  114. },
  115. option: {},
  116. optionBack: {
  117. height: 'auto',
  118. calcHeight: 30,
  119. menuWidth: 140,
  120. border: true,
  121. index: true,
  122. addBtn: false,
  123. viewBtn: false,
  124. editBtn: false,
  125. delBtn: false,
  126. refreshBtn: false,
  127. align: 'center',
  128. column: [
  129. {
  130. label: "费用名称",
  131. prop: "feeName",
  132. overHidden: true
  133. },
  134. {
  135. label: "计价单位",
  136. prop: "feeUnit",
  137. // cell: true,
  138. type: 'select',
  139. filterable: true,
  140. remote: true,
  141. dicUrl: "/api/blade-los/bunits/list",
  142. props: {
  143. label: 'cnName',
  144. value: 'cnName',
  145. res: 'data.records'
  146. },
  147. overHidden: true
  148. },
  149. {
  150. label: "商品类别",
  151. prop: "goodsType",
  152. cell: true,
  153. slot: true,
  154. formslot: true,
  155. overHidden: true,
  156. rules: [
  157. {
  158. required: true,
  159. message: '请选择商品类别',
  160. trigger: 'blur'
  161. }
  162. ]
  163. },
  164. // {
  165. // label: "开始天数",
  166. // prop: "fromDays",
  167. // cell: true,
  168. // type: 'number',
  169. // controls: false,
  170. // overHidden: true
  171. // },
  172. // {
  173. // label: "结束天数",
  174. // prop: "enDays",
  175. // cell: true,
  176. // type: 'number',
  177. // controls: false,
  178. // overHidden: true
  179. // },
  180. {
  181. label: "应收单价",
  182. prop: "price",
  183. cell: true,
  184. type: 'number',
  185. controls: false,
  186. overHidden: true,
  187. rules: [
  188. {
  189. required: true,
  190. message: '请输入应收单价',
  191. trigger: 'blur'
  192. }
  193. ]
  194. },
  195. {
  196. label: "应付单价",
  197. prop: "priceC",
  198. cell: true,
  199. type: 'number',
  200. controls: false,
  201. overHidden: true,
  202. rules: [
  203. {
  204. required: true,
  205. message: '请输入应付单价',
  206. trigger: 'blur'
  207. }
  208. ]
  209. },
  210. {
  211. label: "备注",
  212. prop: "remarks",
  213. cell: true,
  214. overHidden: true
  215. }
  216. ]
  217. },
  218. }
  219. },
  220. components: {
  221. dicSelect,
  222. },
  223. props: {
  224. detailData: Object
  225. },
  226. async created() {
  227. this.option = await this.getColumnData(this.getColumnName(409), this.optionBack);
  228. if (this.detailData.id) {
  229. this.getDetails(this.detailData.id)
  230. }
  231. },
  232. methods: {
  233. rowEdit(row, index) {
  234. if (row.$cellEdit) {
  235. if (!row.goodsType || !row.price|| !row.priceC) {
  236. this.$refs.crud.rowCell(row, row.$index)
  237. return this.$message.error("请完善明细信息");
  238. }
  239. this.$set(row, '$cellEdit', false)
  240. } else {
  241. this.$set(row, '$cellEdit', true)
  242. }
  243. },
  244. rowDel(row, index) {
  245. this.$confirm("确定将选择数据删除?", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning"
  249. }).then(() => {
  250. if (row.id) {
  251. itemRemove({ ids: row.id }).then(res => {
  252. this.form.storageFeeItemsList.splice(index, 1);
  253. this.$message.success("操作成功!");
  254. });
  255. } else {
  256. this.form.storageFeeItemsList.splice(index, 1);
  257. this.$message.success("操作成功!");
  258. }
  259. }
  260. );
  261. },
  262. rowDicChange(name, row, el) {
  263. if (name == 'feeName') {
  264. if (row) {
  265. el.feeId = row.id
  266. } else {
  267. el.feeId = null
  268. }
  269. }
  270. },
  271. getDetails(id) {
  272. const loading = this.$loading({
  273. lock: true,
  274. text: '加载中',
  275. spinner: 'el-icon-loading',
  276. background: 'rgba(255,255,255,0.7)'
  277. });
  278. getBtrademodesDetail(id).then(res => {
  279. this.form = res.data.data
  280. console.log(this.form)
  281. this.$refs.crud.dicInit();
  282. }).finally(() => {
  283. loading.close()
  284. })
  285. },
  286. getCopydate(id) {
  287. const loading = this.$loading({
  288. lock: true,
  289. text: '加载中',
  290. spinner: 'el-icon-loading',
  291. background: 'rgba(255,255,255,0.7)'
  292. });
  293. copyAgent({ id: id }).then(res => {
  294. this.form = res.data.data
  295. }).finally(() => {
  296. loading.close()
  297. })
  298. },
  299. addRow() {
  300. this.$refs.crud.dicInit();
  301. bfeesList(1, 10, { cnName: '仓储费' }).then(res => {
  302. res.data.data.records.forEach(e => {
  303. if (e.cnName == '仓储费')
  304. this.form.storageFeeItemsList.push({
  305. feeId: e.id,
  306. feeName: e.cnName,
  307. feeUnit: '吨',
  308. $cellEdit: true
  309. })
  310. })
  311. })
  312. },
  313. submit() {
  314. this.$refs["form"].validate((valid, done) => {
  315. done();
  316. if (valid) {
  317. for (let row of this.form.storageFeeItemsList) {
  318. if (!row.goodsType || !row.price|| !row.priceC) {
  319. this.$refs.crud.rowCell(row, row.$index)
  320. return this.$message.error("请完善明细信息");
  321. }
  322. }
  323. const loading = this.$loading({
  324. lock: true,
  325. text: '加载中',
  326. spinner: 'el-icon-loading',
  327. background: 'rgba(255,255,255,0.7)'
  328. });
  329. updateBtrademodes(this.form).then(res => {
  330. this.$message.success("保存成功");
  331. this.getDetails(res.data.data.id)
  332. }).finally(() => {
  333. loading.close();
  334. })
  335. } else {
  336. return false;
  337. }
  338. });
  339. },
  340. //自定义列保存
  341. async saveColumn(ref, option, optionBack, code) {
  342. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  343. if (inSave) {
  344. this.$message.success("保存成功");
  345. //关闭窗口
  346. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  347. }
  348. },
  349. //自定义列重置
  350. async resetColumn(ref, option, optionBack, code) {
  351. this[option] = this[optionBack];
  352. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  353. if (inSave) {
  354. this.$message.success("重置成功");
  355. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  356. }
  357. },
  358. goBack(type) {
  359. this.$emit("goBack", type);
  360. this.$emit('updateKey')
  361. },
  362. }
  363. }
  364. </script>
  365. <style lang="scss" scoped>
  366. ::v-deep .el-form-item {
  367. margin-bottom: 8px !important;
  368. }
  369. ::v-deep .el-table .cell {
  370. padding: 0 2px !important;
  371. .el-form-item {
  372. margin-bottom: 0px !important;
  373. }
  374. }
  375. ::v-deep .avue-crud .el-table .el-form-item__label {
  376. left: -1px;
  377. }
  378. ::v-deep#out-table .back-one {
  379. background: #ecf5ff !important;
  380. }
  381. ::v-deep#out-table .back-two {
  382. background: #ecf5ff !important;
  383. }
  384. </style>