detailsPage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button type="primary" size="small" @click="editCustomer" :disabled="loadingBtn || detailData.status == 1">
  12. 保存数据
  13. </el-button>
  14. </div>
  15. </div>
  16. <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle>
  17. <basic-container v-loading="loadingBtn">
  18. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  19. <template slot="corpId">
  20. <crop-select v-model="form.corpId" corpType="KH" :refresh="false" @getCorpData="getCorpData"
  21. :disabled="detailData.status == 1"></crop-select>
  22. </template>
  23. <!-- <template slot="warehouseId">
  24. <el-cascader v-model="form.warehouseId" :options="storagetreeList" :show-all-levels="false"
  25. :disabled="detailData.status == 1"
  26. :props="{ checkStrictly: true, emitPath: false, label: 'title',multiple: true }" clearable>
  27. </el-cascader>
  28. </template> -->
  29. </avue-form>
  30. </basic-container>
  31. <containerTitle title="基础明细"></containerTitle>
  32. <basic-container v-loading="loadingBtn">
  33. <avue-crud ref="crud" :option="optionList" :data="dataList" :table-loading="loading" @saveColumn="saveColumn"
  34. @resetColumn="resetColumn" :cell-style="cellStyle" @row-save="rowSave" @row-update="addUpdate">
  35. <template slot="menuLeft">
  36. <el-button type="primary" @click="addRow" size="small" :disabled="detailData.status == 1">新增
  37. </el-button>
  38. </template>
  39. <template slot="feeId" slot-scope="{ row,index }">
  40. <breakdown-select v-if="row.$cellEdit" v-model="row.feeId" @selectValue="value => selectValue(value,row)"
  41. :configuration="breakConfiguration">
  42. </breakdown-select>
  43. <span v-else>{{ row.feeName }}</span>
  44. </template>
  45. <template slot="menu" slot-scope="{ row, index }">
  46. <el-button size="small" type="text" @click="rowCell(row, index)" :disabled="detailData.status == 1">{{
  47. row.$cellEdit ? "保存" : "修改" }}</el-button>
  48. <el-button size="small" type="text" @click="rowDel(row, index)" :disabled="detailData.status == 1">删除
  49. </el-button>
  50. </template>
  51. </avue-crud>
  52. </basic-container>
  53. <upload-file ref="uploadFile" title="合同附件" :disabled="detailData.status == 1" :orderFilesList="orderFilesList"
  54. delUrl="" />
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { optionList } from "./js/optionList";
  60. import { getDetail, submit, getStoragetree, getAllgoodstype, getLazylist,itemsubmit } from "@/api/basicData/agreement";
  61. export default {
  62. name: "index",
  63. data() {
  64. return {
  65. loadingBtn: false,
  66. form: {},
  67. dataList: [],
  68. option: {
  69. menuBtn: false,
  70. labelWidth: 130,
  71. column: [
  72. {
  73. label: "合同编号",
  74. prop: "contractNo",
  75. rules: [
  76. {
  77. required: true,
  78. message: "",
  79. trigger: "blur"
  80. }
  81. ],
  82. span: 6,
  83. },
  84. {
  85. label: "制单部门",
  86. prop: "deptId",
  87. rules: [
  88. {
  89. required: true,
  90. message: "",
  91. trigger: "blur"
  92. }
  93. ],
  94. type: "select",
  95. dataType: "string",
  96. props: {
  97. label: "deptName",
  98. value: "id"
  99. },
  100. dicData: [],
  101. span: 6,
  102. },
  103. {
  104. label: "客户名称",
  105. prop: "corpId",
  106. rules: [
  107. {
  108. required: true,
  109. message: "",
  110. trigger: "blur"
  111. }
  112. ],
  113. span: 6,
  114. },
  115. {
  116. label: "贸易方式",
  117. prop: "billType",
  118. type: "select",
  119. dataType: "string",
  120. props: {
  121. label: "dictValue",
  122. value: "dictKey"
  123. },
  124. dicData: [],
  125. multiple: true,
  126. span: 6,
  127. },
  128. {
  129. label: "有效期起",
  130. prop: "beginDate",
  131. type: "date",
  132. format: "yyyy-MM-dd",
  133. valueFormat: "yyyy-MM-dd",
  134. span: 6,
  135. },
  136. {
  137. label: "有效期至",
  138. prop: "endDate",
  139. type: "date",
  140. format: "yyyy-MM-dd",
  141. valueFormat: "yyyy-MM-dd",
  142. span: 6,
  143. },
  144. {
  145. label: "商品名称",
  146. prop: "goodsId",
  147. type: "select",
  148. dataType: "string",
  149. props: {
  150. label: "cname",
  151. value: "id"
  152. },
  153. dicData: [],
  154. multiple: true,
  155. span: 6,
  156. },
  157. {
  158. label: "仓库",
  159. prop: "warehouseId",
  160. type: "cascader",
  161. dataType: "string",
  162. dicData: [],
  163. props: {
  164. label: 'title',
  165. value: 'id'
  166. },
  167. multiple: true,
  168. span: 6,
  169. },
  170. {
  171. label: "状态",
  172. prop: "billStatus",
  173. type: "select",
  174. props: {
  175. label: "dictValue",
  176. value: "dictKey"
  177. },
  178. dicData: [],
  179. disabled: true,
  180. span: 6,
  181. },
  182. {
  183. label: "备注",
  184. prop: "remark",
  185. type: "textarea",
  186. minRows: 2,
  187. width: 120,
  188. span: 18,
  189. },
  190. ]
  191. },
  192. optionList: {},
  193. resultList: [],
  194. normTypeList: [],
  195. jobTitleList: [],
  196. jobLevelList: [],
  197. occupationalLevelList: [],
  198. maritalList: [],
  199. orderFilesList: [],
  200. storagetreeList: [],
  201. breakConfiguration: {
  202. multipleChoices: false,
  203. multiple: false,
  204. disabled: false,
  205. searchShow: true,
  206. collapseTags: false,
  207. clearable: true,
  208. placeholder: "请点击右边按钮选择",
  209. dicData: []
  210. },
  211. };
  212. },
  213. props: {
  214. detailData: {
  215. type: Object
  216. }
  217. },
  218. async created() {
  219. this.optionList = await this.getColumnData(
  220. this.getColumnName(193),
  221. optionList
  222. );
  223. if (this.detailData.id) {
  224. this.getDetail(this.detailData.id);
  225. }
  226. if (this.detailData.status == 1) {
  227. this.option.disabled = true;
  228. }
  229. this.getWorkDicts("result_type").then(res => {
  230. this.resultList = res.data.data;
  231. });
  232. this.getWorkDicts("trading_type").then(res => {
  233. this.findObject(this.option.column, "billType").dicData =
  234. res.data.data;
  235. });
  236. this.getWorkDicts("bill_status").then(res => {
  237. this.findObject(this.option.column, "billSdtatus").dicData = res.data.data;
  238. });
  239. getStoragetree().then(res => {
  240. this.findObject(this.option.column, "warehouseId").dicData = res.data.data;
  241. })
  242. getAllgoodstype().then(res => {
  243. this.findObject(this.option.column, "goodsId").dicData =
  244. res.data.data;
  245. })
  246. getLazylist().then(res => {
  247. this.findObject(this.option.column, "deptId").dicData =
  248. res.data.data;
  249. })
  250. this.getAllWorkDicts()
  251. },
  252. methods: {
  253. getAllWorkDicts() {
  254. this.getWorkDicts("unit").then(res => {
  255. this.findObject(this.optionList.column, "feeUnitId").dicData =
  256. res.data.data;
  257. });
  258. },
  259. cellStyle() {
  260. return "padding:0;height:40px;";
  261. },
  262. selectValue(value,row) {
  263. console.log(value,row)
  264. if(row.feeId){
  265. row.feeName=value.cname
  266. }else{
  267. row.feeName=""
  268. }
  269. },
  270. getDetail(id) {
  271. this.loadingBtn=true
  272. getDetail(id)
  273. .then(res => {
  274. // if (res.data.data.warehouseId) {
  275. // res.data.data.warehouseId = res.data.data.warehouseId.split(',')
  276. // }
  277. this.form = res.data.data;
  278. this.dataList = res.data.data.agreementitemsList;
  279. this.orderFilesList = res.data.data.orderFilesList
  280. })
  281. .finally(() => {
  282. // this.loading = false;
  283. // this.showBut = true;
  284. this.loadingBtn = false;
  285. });
  286. },
  287. getCorpData(row) {
  288. this.form.corpName = row.cname
  289. },
  290. addRow() {
  291. this.dataList.push({ $cellEdit: true });
  292. },
  293. // rowCell(row, index) {
  294. // if (row.$cellEdit == true) {
  295. // this.editCustomer();
  296. // this.$set(row, "$cellEdit", false);
  297. // } else {
  298. // this.$set(row, "$cellEdit", true);
  299. // }
  300. // },
  301. rowCell(row, index) {
  302. this.$refs.crud.rowCell(row, index)
  303. },
  304. rowSave(form, done) {
  305. done()
  306. this.itemsubmit(form)
  307. },
  308. addUpdate(form, index, done, loading) {
  309. done()
  310. this.itemsubmit(form)
  311. },
  312. itemsubmit(row){
  313. itemsubmit({
  314. pid:this.form.id,
  315. ...row
  316. }).then(res=>{
  317. this.$message.success("保存成功");
  318. })
  319. },
  320. rowDel(row, index) {
  321. this.$confirm("确定删除数据?", {
  322. confirmButtonText: "确定",
  323. cancelButtonText: "取消",
  324. type: "warning"
  325. }).then(() => {
  326. if (row.id) {
  327. // delItem(row.id).then(res => {
  328. // this.$message({
  329. // type: "success",
  330. // message: "删除成功!"
  331. // });
  332. // this.dataList.splice(index, 1);
  333. // });
  334. } else {
  335. this.$message({
  336. type: "success",
  337. message: "删除成功!"
  338. });
  339. this.dataList.splice(index, 1);
  340. }
  341. });
  342. },
  343. //修改提交触发
  344. editCustomer() {
  345. this.$refs["form"].validate((valid, done) => {
  346. done();
  347. if (valid) {
  348. // if (this.form.warehouseId) {
  349. // this.form.warehouseId = this.form.warehouseId.join(',')
  350. // }
  351. this.loadingBtn = true;
  352. submit({ ...this.form, agreementitemsList: this.dataList })
  353. .then(res => {
  354. this.$message.success("保存成功");
  355. // if (res.data.data.data.warehouseId) {
  356. // res.data.data.data.warehouseId = res.data.data.data.warehouseId.split(',')
  357. // }
  358. console.log()
  359. this.form = res.data.data.data;
  360. this.dataList = res.data.data.data.agreementitemsList;
  361. this.orderFilesList = res.data.data.orderFilesList
  362. })
  363. .finally(() => {
  364. this.loadingBtn = false;
  365. });
  366. } else {
  367. return false;
  368. }
  369. });
  370. },
  371. async saveColumn() {
  372. const inSave = await this.saveColumnData(
  373. this.getColumnName(193),
  374. this.optionList
  375. );
  376. if (inSave) {
  377. this.$nextTick(() => {
  378. this.$refs.crud.doLayout();
  379. });
  380. this.$message.success("保存成功");
  381. //关闭窗口
  382. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  383. }
  384. },
  385. async resetColumn() {
  386. this.optionList = optionList;
  387. const inSave = await this.delColumnData(
  388. this.getColumnName(193),
  389. optionList
  390. );
  391. if (inSave) {
  392. this.$nextTick(() => {
  393. this.$refs.crud.doLayout();
  394. });
  395. this.getAllWorkDicts()
  396. this.$message.success("重置成功");
  397. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  398. }
  399. },
  400. //返回列表
  401. backToList() {
  402. this.$emit("goBack");
  403. }
  404. }
  405. };
  406. </script>
  407. <style lang="scss" scoped>
  408. .trading-form ::v-deep .el-form-item {
  409. margin-bottom: 8px !important;
  410. }
  411. ::v-deep .el-form-item__error {
  412. display: none !important;
  413. }
  414. .img-form ::v-deep .el-form-item {
  415. height: 150px;
  416. line-height: 150px;
  417. margin-bottom: 8px !important;
  418. }
  419. .img-form ::v-deep .avue-upload__icon {
  420. font-size: 20px;
  421. width: 150px;
  422. height: 150px;
  423. line-height: 150px;
  424. }
  425. ::v-deep .el-table .cell {
  426. padding: 0 2px !important;
  427. }
  428. ::v-deep .avue-crud .el-table .el-form-item__label {
  429. left: -1px;
  430. }
  431. </style>