detail.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. :loading="btnLoading"
  11. >返回列表</el-button>
  12. </div>
  13. <div class="add-customer-btn">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. class="el-button--small-yh"
  18. @click.stop="openEdit"
  19. >编 辑</el-button>
  20. <el-button
  21. type="success"
  22. :disabled="!form.id"
  23. size="small"
  24. @click="copyDoc"
  25. :loading="btnLoading"
  26. >复制单据</el-button>
  27. <el-button
  28. type="primary"
  29. @click="editCustomer"
  30. size="small"
  31. :loading="btnLoading"
  32. >保存数据</el-button>
  33. </div>
  34. </div>
  35. <div class="customer-main">
  36. <containerTitle title="基础信息"/>
  37. <basic-container :showBtn="true">
  38. <avue-form
  39. ref="form"
  40. class="trading-form"
  41. v-model="form"
  42. :option="option"
  43. >
  44. <template slot="corpId">
  45. <crop-select
  46. v-model="form.corpId"
  47. @getCorpData="getKHData"
  48. corpType="KH"
  49. />
  50. </template>
  51. <template slot="createUser">
  52. <el-select
  53. v-model="form.createUser"
  54. filterable
  55. clearable
  56. size="small"
  57. >
  58. <el-option
  59. v-for="(item,index) in userList"
  60. :key="index"
  61. :label="item.realName"
  62. :value="item.realName"
  63. ></el-option>
  64. </el-select>
  65. </template>
  66. <template slot="oppositePerson">
  67. <el-select
  68. v-model="form.oppositePerson"
  69. filterable
  70. clearable
  71. size="small"
  72. >
  73. <el-option
  74. v-for="(item,index) in userList"
  75. :key="index"
  76. :label="item.realName"
  77. :value="item.realName"
  78. ></el-option>
  79. </el-select>
  80. </template>
  81. </avue-form>
  82. </basic-container>
  83. <containerTitle title="详情内容"/>
  84. <basic-container>
  85. <avue-crud
  86. ref="crud"
  87. :data="dataList"
  88. :option="tableOption"
  89. :cell-style="cellStyle"
  90. @saveColumn="saveColumn"
  91. @resetColumn="resetColumn"
  92. >
  93. <template slot="menuLeft">
  94. <el-button
  95. type="primary"
  96. icon="el-icon-plus"
  97. size="small"
  98. @click.stop="newDetails"
  99. >录入明细</el-button>
  100. <el-button
  101. type="info"
  102. icon="el-icon-printer"
  103. size="small"
  104. >报表打印</el-button>
  105. </template>
  106. <template slot="menu" slot-scope="{ row, index }">
  107. <el-button
  108. size="small"
  109. icon="el-icon-edit"
  110. type="text"
  111. @click="rowCell(row, index)"
  112. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
  113. <el-button
  114. size="small"
  115. icon="el-icon-delete"
  116. type="text"
  117. @click="rowDel(row, index)"
  118. >删除</el-button>
  119. </template>
  120. </avue-crud>
  121. </basic-container>
  122. </div>
  123. </div>
  124. </template>
  125. <script>
  126. import tableOption from "./config/customerContact.json";
  127. import {
  128. isDiscount,
  129. isPercentage,
  130. micrometerFormat,
  131. IntegerFormat
  132. } from "@/util/validate";
  133. import { gainUser } from "@/api/basicData/customerInquiry";
  134. import {getUserInfo} from "@/api/system/user";
  135. import {getDeptTree} from "@/api/system/dept";
  136. import { getCurrentDate } from "@/util/date";
  137. export default {
  138. name: "detail",
  139. data() {
  140. return {
  141. pageLoading: false,
  142. btnLoading: false,
  143. form: {},
  144. option: {
  145. menuBtn: false,
  146. labelWidth: 100,
  147. column: [
  148. {
  149. label: "客户名称",
  150. prop: "corpId",
  151. rules: [
  152. {
  153. required: true,
  154. message: " ",
  155. trigger: "change"
  156. }
  157. ],
  158. span: 8,
  159. slot: true,
  160. },
  161. {
  162. label: "交接日期",
  163. prop: "b",
  164. span: 8,
  165. type: "date",
  166. format: "yyyy-MM-dd",
  167. valueFormat: "yyyy-MM-dd 00:00:00",
  168. rules: [
  169. {
  170. required: true,
  171. message: " ",
  172. trigger: "blur"
  173. }
  174. ]
  175. },
  176. {
  177. label: "NO.",
  178. prop: "sysNo",
  179. disabled:true,
  180. span: 8,
  181. },
  182. {
  183. label: "交接人",
  184. prop: "handoverPerson",
  185. span: 8,
  186. },
  187. {
  188. label: "联系人",
  189. prop: "contacts",
  190. span: 8,
  191. },
  192. {
  193. label: "交接备注",
  194. prop: "orderRemark",
  195. type: "textarea",
  196. minRows: 2,
  197. span: 24,
  198. },
  199. ],
  200. },
  201. dataList: [],
  202. tableOption: {},
  203. goodsoptions: [],
  204. unitOption: [],
  205. selectionList: [],
  206. search: {},
  207. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  208. goodsOption: {},
  209. loading: false,
  210. switchDialog: false, // 报表弹窗控制
  211. userList: [],
  212. dic: [],
  213. loginUser: '', // 登录人
  214. }
  215. },
  216. async created() {
  217. this.$set(this.form, 'b', getCurrentDate()); // 默认当前日期
  218. this.tableOption = await this.getColumnData(
  219. this.getColumnName(104),
  220. tableOption
  221. );
  222. gainUser().then(res => {
  223. this.userList = res.data.data;
  224. });
  225. getUserInfo().then(res => {
  226. this.$set(this.form, 'createUser', res.data.data.realName);
  227. this.$set(this.form, 'oppositePerson', res.data.data.realName);
  228. this.loginUser = res.data.data.realName;
  229. })
  230. getDeptTree().then(res => {
  231. this.dic = res.data.data
  232. })
  233. this.getWorkDicts('unit').then(res => {
  234. this.unitOption = res.data.data;
  235. })
  236. },
  237. filters: {
  238. IntegerFormat(num) {
  239. return IntegerFormat(num);
  240. },
  241. decimalFormat(num) {
  242. return num ? Number(num).toFixed(2) : "0.00";
  243. }
  244. },
  245. methods: {
  246. //返回列表
  247. backToList() {
  248. this.$emit("goBack");
  249. },
  250. // 编辑按钮触发
  251. openEdit() {},
  252. // 复制
  253. copyDoc() {
  254. this.$emit("copyOrder", this.form.id);
  255. },
  256. //修改提交触发
  257. editCustomer(status) {
  258. this.$refs["form"].validate((valid, done) => {
  259. done();
  260. if (valid) {
  261. // this.btnLoading = true;
  262. // typeSave(this.form).then(res => {
  263. // this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  264. // this.queryData(res.data.data.id);
  265. // }).finally(() => {
  266. // this.btnLoading = false;
  267. // })
  268. } else {
  269. return false
  270. }
  271. })
  272. },
  273. cellStyle() {
  274. return "padding:0;height:40px;";
  275. },
  276. async saveColumn() {
  277. const inSave = await this.saveColumnData(
  278. this.getColumnName(104),
  279. this.tableOption
  280. );
  281. if (inSave) {
  282. this.$message.success("保存成功");
  283. //关闭窗口
  284. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  285. this.$nextTick(() => {
  286. this.$refs.crud.doLayout()
  287. })
  288. }
  289. },
  290. async resetColumn() {
  291. this.tableOption = tableOption;
  292. const inSave = await this.delColumnData(
  293. this.getColumnName(104),
  294. tableOption
  295. );
  296. if (inSave) {
  297. this.$nextTick(() => {
  298. this.$refs.crud.doLayout()
  299. })
  300. this.$message.success("重置成功");
  301. //关闭窗口
  302. setTimeout(() => {
  303. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  304. }, 1000);
  305. }
  306. },
  307. //录入明细
  308. newDetails() {
  309. this.$refs["form"].validate((valid, done) => {
  310. done()
  311. if (valid) {
  312. this.dataList.push({
  313. createTime: getCurrentDate('date'),
  314. createUser: this.loginUser,
  315. $cellEdit: true,
  316. })
  317. }
  318. })
  319. },
  320. rowCell(row, index) {
  321. if (row.$cellEdit == true) {
  322. this.$set(row, "$cellEdit", false);
  323. } else {
  324. this.$set(row, "$cellEdit", true);
  325. }
  326. },
  327. rowDel(row, index) {
  328. this.$confirm("确定删除数据?", {
  329. confirmButtonText: "确定",
  330. cancelButtonText: "取消",
  331. type: "warning"
  332. }).then(() => {
  333. if (row.id) {
  334. // removeGoods(row.id).then(res => {
  335. // this.$message({
  336. // type: 'success',
  337. // message: '删除成功!'
  338. // })
  339. // this.dataList.splice(row.$index, 1);
  340. // })
  341. } else {
  342. this.$message({
  343. type: "success",
  344. message: "删除成功!"
  345. });
  346. this.dataList.splice(row.$index, 1);
  347. }
  348. });
  349. },
  350. getKHData(row) {},
  351. },
  352. }
  353. </script>
  354. <style scoped>
  355. </style>