engin_form.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">工程信息单</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="100px" size="small" label-position="left">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="工程信息单" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" readonly></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. type="date"
  19. value-format="yyyy-MM-dd"
  20. style="width: 100%;"
  21. placeholder="选择日期">
  22. </el-date-picker>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :xs="24" :sm="12" :lg="8">
  26. <el-form-item label="产品大类" prop="mainId">
  27. <el-select v-model="mainForm.mainId" placeholder="选择产品大类" style="width: 100%">
  28. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :xs="24" :sm="12" :lg="8">
  33. <el-form-item label="经销商编码" prop="jxsNum">
  34. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" readonly></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :lg="8">
  38. <el-form-item label="项目名称" prop="enginName">
  39. <el-input v-model="mainForm.enginName" placeholder="请输入项目名称"></el-input>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :xs="24" :sm="12" :lg="8">
  43. <el-form-item label="单据类型" prop="orderType">
  44. <el-input v-model="mainForm.orderType" placeholder="请输入单据类型"></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :xs="24" :sm="12" :lg="8">
  48. <el-form-item label="经销商名称" prop="jxsName">
  49. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" readonly></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :xs="24" :sm="12" :lg="8">
  53. <el-form-item label="使用单位" prop="company">
  54. <el-input v-model="mainForm.company" placeholder="请输入使用单位"></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :xs="24" :sm="12" :lg="8">
  58. <el-form-item label="安装地址" prop="address">
  59. <el-input v-model="mainForm.address" placeholder="请输入安装地址"></el-input>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xs="24" :sm="12" :lg="8">
  63. <el-form-item label="工程编号" prop="enginNum">
  64. <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号"></el-input>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :xs="24" :sm="12" :lg="8">
  68. <el-form-item label="厂工程编码" prop="factoryNum">
  69. <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编码"></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :xs="24" :sm="12" :lg="8">
  73. <el-form-item label="工程登录类型" prop="loginType">
  74. <el-input v-model="mainForm.loginType" placeholder="请输入工程登录类型"></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :xs="24" :sm="24" :lg="16">
  78. <el-form-item label="备注" prop="remark">
  79. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :xs="24" :sm="12" :lg="8">
  83. <el-form-item label="业务员" prop="salesMan">
  84. <el-input v-model="mainForm.salesMan" placeholder="请输入业务员" readonly></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :xs="24" :sm="12" :lg="8">
  88. <el-form-item label="制单人" prop="createMan">
  89. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" readonly></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  93. <el-form-item label="制单日期" prop="createDate">
  94. <el-date-picker
  95. v-model="mainForm.createDate"
  96. type="date"
  97. readonly
  98. value-format="yyyy-MM-dd"
  99. style="width: 100%;"
  100. placeholder="选择日期">
  101. </el-date-picker>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  105. <el-form-item label="合同有效期" prop="contractDate">
  106. <el-date-picker
  107. v-model="mainForm.contractDate"
  108. type="date"
  109. value-format="yyyy-MM-dd"
  110. style="width: 100%;"
  111. placeholder="选择日期">
  112. </el-date-picker>
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. </el-form>
  117. <div class="main-title">
  118. <div class="title">货品信息</div>
  119. </div>
  120. <div class="table" style="margin-top: 20px">
  121. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  122. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  123. <el-table-column align="center" label="销售类型" prop="saleTypeId" min-width="160" show-overflow-tooltip>
  124. <template slot-scope="scope">
  125. <el-select v-model="scope.row.saleTypeId" placeholder="选择销售类型" size="small" @change="changeSaleType(scope.$index)">
  126. <el-option
  127. v-for="item in salesTypeList"
  128. :key="item.id"
  129. :label="item.saleName"
  130. :value="item.id">
  131. </el-option>
  132. </el-select>
  133. </template>
  134. </el-table-column>
  135. <el-table-column align="center" label="产品名称" prop="materialNumber" min-width="160" show-overflow-tooltip>
  136. <template slot-scope="scope">
  137. <el-select v-model="scope.row.materialNumber" placeholder="选择产品" size="small" @change="changeGoods(scope.$index)">
  138. <el-option
  139. v-for="item in retailProductList"
  140. :key="item.number"
  141. :label="item.name"
  142. :value="item.number">
  143. </el-option>
  144. </el-select>
  145. </template>
  146. </el-table-column>
  147. <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  148. <el-table-column align="center" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip></el-table-column>
  149. <el-table-column align="center" label="单位" prop="baseUnitId" min-width="100" show-overflow-tooltip></el-table-column>
  150. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  151. <template slot-scope="scope">
  152. <el-input v-model="scope.row.price" size="small" type="number"></el-input>
  153. </template>
  154. </el-table-column>
  155. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  156. <template slot-scope="scope">
  157. <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
  158. </template>
  159. </el-table-column>
  160. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  161. <template slot-scope="scope">
  162. {{(scope.row.price || 0) * (scope.row.qty || 0)}}
  163. </template>
  164. </el-table-column>
  165. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  166. <template slot-scope="scope">
  167. <el-input v-model="scope.row.remark" size="small"></el-input>
  168. </template>
  169. </el-table-column>
  170. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip></el-table-column>
  171. <el-table-column align="center" label="操作" width="100" fixed="right">
  172. <template slot-scope="scope">
  173. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <div class="add"><el-button type="text" icon="el-icon-plus" @click="addGoods">添加产品</el-button></div>
  178. </div>
  179. <div class="page-footer">
  180. <div class="footer" :class="classObj">
  181. <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
  182. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  183. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  184. <el-button slot="reference">关 闭</el-button>
  185. </el-popconfirm>
  186. </div>
  187. </div>
  188. </div>
  189. </template>
  190. <script>
  191. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from "@/api/supply/engin";
  192. import { getDictList, getTypeList } from '@/api/common'
  193. export default {
  194. name: 'EnginForm',
  195. componentName: 'EnginForm',
  196. props: ['listItem'],
  197. data() {
  198. return {
  199. goodsList: [],
  200. mainForm: {
  201. orderNum: '',
  202. orderDate: '',
  203. mainId: '102',
  204. jxsNum: '',
  205. enginName: '',
  206. orderType: '',
  207. jxsName: '',
  208. company: '',
  209. address: '',
  210. enginNum: '',
  211. factoryNum: '',
  212. loginType: '',
  213. remark: '',
  214. salesMan: '',
  215. createMan: '',
  216. createDate: '',
  217. contractDate: '',
  218. },
  219. mainFormRules: {
  220. orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  221. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  222. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  223. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  224. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  225. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  226. },
  227. typeList: [],
  228. salesTypeList: [],
  229. retailProductList: [],
  230. }
  231. },
  232. computed: {
  233. sidebar() {
  234. return this.$store.state.app.sidebar
  235. },
  236. classObj() {
  237. return {
  238. hideSidebar: !this.sidebar.opened,
  239. openSidebar: this.sidebar.opened
  240. }
  241. },
  242. },
  243. created() {
  244. this.getDictList();
  245. this.getTypeList();
  246. this.getRetailProductList();
  247. if(this.listItem) {
  248. this.getDetail();
  249. }else {
  250. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerId;
  251. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  252. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  253. this.mainForm.createDate = this.getDate(0);
  254. this.mainForm.contractDate = this.getDate(1);
  255. }
  256. },
  257. methods: {
  258. // 返回列表
  259. goBack() {
  260. this.$emit('backListFormDetail');
  261. },
  262. getDate(addYear) {
  263. var date = new Date();
  264. var seperator1 = "-";
  265. var year = date.getFullYear() + addYear;
  266. var month = date.getMonth() + 1;
  267. var strDate = date.getDate();
  268. if (month >= 1 && month <= 9) {
  269. month = "0" + month;
  270. }
  271. if (strDate >= 0 && strDate <= 9) {
  272. strDate = "0" + strDate;
  273. }
  274. var currentdate = year + seperator1 + month + seperator1 + strDate;
  275. return currentdate;
  276. },
  277. // 获取详情
  278. getDetail() {
  279. getEnginDetail({id: this.listItem.enginInfoId}).then(res => {
  280. let data = res.data;
  281. this.mainForm.orderNum = data.enginInfoNo;
  282. this.mainForm.orderDate = data.orderDate;
  283. this.mainForm.mainId = data.productCategoryId;
  284. this.mainForm.jxsNum = data.customerId;
  285. this.mainForm.enginName = data.projectName;
  286. this.mainForm.orderType = data.orderType;
  287. this.mainForm.jxsName = data.customerName;
  288. this.mainForm.company = data.useUnit;
  289. this.mainForm.address = data.installAddress;
  290. this.mainForm.enginNum = data.projectNo;
  291. this.mainForm.factoryNum = data.enginFactoryNo;
  292. this.mainForm.loginType = data.enginSignType;
  293. this.mainForm.remark = data.remark;
  294. this.mainForm.salesMan = data.serviceId;
  295. this.mainForm.createMan = data.createName;
  296. this.mainForm.createDate = data.createTime;
  297. this.mainForm.contractDate = data.contractExpireDate;
  298. this.goodsList = data.items;
  299. })
  300. },
  301. // 获取产品大类列表
  302. getDictList() {
  303. getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  304. this.typeList = res.data;
  305. })
  306. },
  307. // 获取销售类型列表
  308. getTypeList() {
  309. getTypeList({
  310. pageNum: 1,
  311. pageSize: -1,
  312. }).then((res) => {
  313. this.salesTypeList = res.data.records;
  314. });
  315. },
  316. // 获取商品列表
  317. getRetailProductList() {
  318. getRetailProductList({
  319. pageNum: 1,
  320. pageSize: -1,
  321. }).then(res => {
  322. this.retailProductList = res.data.records;
  323. })
  324. },
  325. // 修改销售类型
  326. changeSaleType(index) {
  327. if(this.goodsList[index].saleTypeId) {
  328. let obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId);
  329. this.goodsList[index].saleTypeName = obj.saleName;
  330. this.goodsList[index].saleTypeCode = obj.saleCode;
  331. }
  332. },
  333. // 修改产品
  334. changeGoods(index) {
  335. if(this.goodsList[index].materialNumber) {
  336. let obj = this.retailProductList.find(o => o.number == this.goodsList[index].materialNumber);
  337. this.goodsList[index].materialName = obj.name;
  338. this.goodsList[index].materialId = obj.materialId;
  339. this.goodsList[index].specification = obj.specification;
  340. this.goodsList[index].baseUnitId = obj.baseUnit;
  341. this.goodsList[index].price = obj.batchPrice;
  342. this.goodsList[index].taxRate = obj.taxRate;
  343. this.goodsList[index].mainId = obj.mainId;
  344. }
  345. },
  346. // 添加产品
  347. addGoods() {
  348. this.goodsList.push({})
  349. },
  350. // 删除产品
  351. deleteItem(index) {
  352. this.goodsList.splice(index, 1);
  353. },
  354. clickSubmitForm(type) {
  355. this.$refs.mainForm.validate((valid) => {
  356. if (valid) {
  357. for(let i=0; i<this.goodsList.length; i++) {
  358. if(!this.goodsList[i].saleTypeId) {
  359. this.$errorMsg('请选择销售类型');
  360. return;
  361. }
  362. }
  363. for(let i=0; i<this.goodsList.length; i++) {
  364. if(!this.goodsList[i].materialNumber) {
  365. this.$errorMsg('请选择产品');
  366. return;
  367. }
  368. }
  369. for(let i=0; i<this.goodsList.length; i++) {
  370. if(!this.goodsList[i].qty) {
  371. this.$errorMsg('请输入数量');
  372. return;
  373. }
  374. }
  375. let params = {
  376. orderDate: this.mainForm.orderDate + ' 00:00:00',
  377. productCategoryId: this.mainForm.mainId,
  378. projectName: this.mainForm.enginName,
  379. orderType: this.mainForm.orderType,
  380. useUnit: this.mainForm.company,
  381. installAddress: this.mainForm.address,
  382. projectNo: this.mainForm.enginNum,
  383. enginFactoryNo: this.mainForm.factoryNum,
  384. enginSignType: this.mainForm.loginType,
  385. remark: this.mainForm.remark,
  386. contractExpireDate: this.mainForm.contractDate,
  387. items: this.goodsList
  388. }
  389. if(type === 1) {
  390. if(this.listItem) {
  391. params.enginInfoId = this.listItem.enginInfoId;
  392. editEngin(params).then(res => {
  393. this.$successMsg('编辑成功');
  394. this.goBack();
  395. this.$parent.getList();
  396. })
  397. }else {
  398. addEngin(params).then(res => {
  399. this.$successMsg('保存成功');
  400. this.goBack();
  401. this.$parent.getList();
  402. })
  403. }
  404. }else {
  405. if(this.listItem) {
  406. params.enginInfoId = this.listItem.enginInfoId;
  407. }
  408. submitEngin(params).then(res => {
  409. this.$successMsg('提交审核成功');
  410. this.goBack();
  411. this.$parent.getList();
  412. })
  413. }
  414. }
  415. })
  416. },
  417. }
  418. }
  419. </script>
  420. <style scoped lang="scss">
  421. .detail-container {
  422. width: 100%;
  423. height: 100%;
  424. }
  425. .main-title {
  426. display: flex;
  427. justify-content: space-between;
  428. align-items: center;
  429. margin-top: 20px;
  430. height: 60px;
  431. border-bottom: 1px solid #DCDFE6;
  432. margin-bottom: 20px;
  433. .title {
  434. font-size: 16px;
  435. font-weight: 600;
  436. padding-left: 10px;
  437. }
  438. }
  439. .add {
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. border: 1px solid #EBEEF5;
  444. border-top: none;
  445. height: 50px;
  446. }
  447. ::v-deep input::-webkit-outer-spin-button,
  448. ::v-deep input::-webkit-inner-spin-button {
  449. -webkit-appearance: none;
  450. }
  451. ::v-deep input[type='number'] {
  452. -moz-appearance: textfield;
  453. }
  454. </style>