engin_form.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header :content="listItem ? '编辑' : '新增'" @back="goBack" />
  4. <div class="main-title">
  5. <div class="title">工程信息单</div>
  6. </div>
  7. <el-form
  8. ref="mainForm"
  9. :model="mainForm"
  10. :rules="mainFormRules"
  11. label-width="110px"
  12. size="small"
  13. label-position="right"
  14. >
  15. <el-row :gutter="20">
  16. <el-col :xs="24" :sm="12" :lg="8">
  17. <el-form-item label="工程登录编号" prop="orderNum">
  18. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  22. <el-form-item label="单据日期" prop="orderDate">
  23. <el-date-picker
  24. v-model="mainForm.orderDate"
  25. disabled
  26. type="date"
  27. value-format="yyyy-MM-dd"
  28. style="width: 100%"
  29. placeholder="系统自动生成"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8">
  34. <el-form-item label="业务员" prop="salesMan">
  35. <el-select
  36. v-model="mainForm.salesMan"
  37. placeholder="选择业务员"
  38. size="small"
  39. filterable
  40. clearable
  41. style="width: 100%"
  42. >
  43. <el-option
  44. v-for="item in salesmanList"
  45. :key="item.adminUserId"
  46. :label="item.nickName"
  47. :value="item.adminUserId"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <!-- <el-col :xs="24" :sm="12" :lg="8">
  53. <el-form-item label="产品大类" prop="mainId">
  54. <el-select v-model="mainForm.mainId" placeholder="选择产品大类" style="width: 100%">
  55. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col> -->
  59. </el-row>
  60. <el-row :gutter="20">
  61. <el-col :xs="24" :sm="12" :lg="8">
  62. <el-form-item label="经销商编码" prop="jxsNum">
  63. <el-input v-model="mainForm.jxsNum" placeholder="选择经销商" disabled />
  64. </el-form-item>
  65. </el-col>
  66. <el-col :xs="24" :sm="12" :lg="8">
  67. <el-form-item label="项目名称" prop="enginName">
  68. <el-input v-model="mainForm.enginName" placeholder="请输入项目名称" />
  69. </el-form-item>
  70. </el-col>
  71. <el-col :xs="24" :sm="12" :lg="8">
  72. <el-form-item label="机型类别" prop="machineType">
  73. <el-select
  74. v-model="mainForm.machineType"
  75. placeholder="选择机型类别"
  76. size="small"
  77. clearable
  78. style="width: 100%"
  79. >
  80. <el-option
  81. v-for="item in machineTypeList"
  82. :key="item.dictCode"
  83. :label="item.dictValue"
  84. :value="item.dictCode"
  85. />
  86. </el-select>
  87. </el-form-item>
  88. </el-col>
  89. <el-col :xs="24" :sm="12" :lg="8">
  90. <el-form-item label="经销商名称" prop="jxsNum">
  91. <el-select
  92. v-model="mainForm.jxsNum"
  93. placeholder="选择经销商"
  94. size="small"
  95. filterable
  96. clearable
  97. style="width: 100%"
  98. :disabled="listItem != undefined"
  99. @change="changeDealer"
  100. >
  101. <el-option v-for="item in dealerList" :key="item.number" :label="item.name" :value="item.number" />
  102. </el-select>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :xs="24" :sm="12" :lg="8">
  106. <el-form-item label="使用单位" prop="company">
  107. <el-input v-model="mainForm.company" placeholder="请输入使用单位" />
  108. </el-form-item>
  109. </el-col>
  110. <el-col :xs="24" :sm="12" :lg="8">
  111. <el-form-item label="行业类别" prop="tradeCategory">
  112. <el-select
  113. v-model="mainForm.tradeCategory"
  114. placeholder="选择行业类别"
  115. size="small"
  116. clearable
  117. style="width: 100%"
  118. >
  119. <el-option v-for="item in tradeCategoryList" :key="item.value" :label="item.label" :value="item.value" />
  120. </el-select>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :xs="24" :sm="12" :lg="8">
  124. <el-form-item label="工程编号" prop="enginNum">
  125. <el-input v-model="mainForm.enginNum" placeholder="请输入工程编号" />
  126. </el-form-item>
  127. </el-col>
  128. <el-col :xs="24" :sm="12" :lg="8">
  129. <el-form-item label="厂工程编码" prop="factoryNum">
  130. <el-input v-model="mainForm.factoryNum" placeholder="请输入厂工程编码" />
  131. </el-form-item>
  132. </el-col>
  133. <el-col :xs="24" :sm="12" :lg="8">
  134. <el-form-item label="工程登录类型" prop="loginType">
  135. <el-select
  136. v-model="mainForm.loginType"
  137. placeholder="选择工程登录类型"
  138. size="small"
  139. clearable
  140. style="width: 100%"
  141. >
  142. <el-option
  143. v-for="item in loginTypeList"
  144. :key="item.dictCode"
  145. :label="item.dictValue"
  146. :value="item.dictCode"
  147. />
  148. </el-select>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :xs="24" :sm="12" :lg="8">
  152. <el-form-item label="联系人" prop="linkman">
  153. <el-input v-model="mainForm.linkman" placeholder="请输入联系人" />
  154. </el-form-item>
  155. </el-col>
  156. <el-col :xs="24" :sm="12" :lg="8">
  157. <el-form-item label="联系电话" prop="phone">
  158. <el-input v-model="mainForm.phone" placeholder="请输入联系电话" />
  159. </el-form-item>
  160. </el-col>
  161. <el-col :xs="24" :sm="12" :lg="8">
  162. <el-form-item label="固定电话" prop="tel">
  163. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" />
  164. </el-form-item>
  165. </el-col>
  166. <el-col :xs="24" :sm="16" :lg="16">
  167. <el-form-item label="安装地址" prop="address">
  168. <el-input v-model="mainForm.address" placeholder="请输入安装地址" />
  169. </el-form-item>
  170. </el-col>
  171. <el-col :xs="24" :sm="8" :lg="8">
  172. <el-form-item label="文件编号" prop="fileNo">
  173. <el-input v-model="mainForm.fileNo" placeholder="请输入文件编号" />
  174. </el-form-item>
  175. </el-col>
  176. <el-col v-if="!isDealer" :xs="24" :sm="24" :lg="16">
  177. <el-form-item label="格力内部备注" prop="greeRemark">
  178. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注" />
  179. </el-form-item>
  180. </el-col>
  181. <el-col v-if="!isDealer" :xs="24" :sm="12" :lg="8">
  182. <el-form-item label="权限分类" prop="power">
  183. <el-select v-model="mainForm.power" placeholder="选择权限分类" size="small" clearable style="width: 100%">
  184. <el-option
  185. v-for="item in powerList"
  186. :key="item.dictCode"
  187. :label="item.dictValue"
  188. :value="item.dictCode"
  189. />
  190. </el-select>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :xs="24" :sm="24" :lg="24">
  194. <el-form-item label="格力回复" prop="greeReply">
  195. <el-input
  196. v-model="mainForm.greeReply"
  197. :placeholder="isDealer ? '' : '请输入格力回复'"
  198. :disabled="isDealer"
  199. />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :xs="24" :sm="24" :lg="24">
  203. <el-form-item label="备注" prop="remark">
  204. <el-input v-model="mainForm.remark" placeholder="请输入备注" />
  205. </el-form-item>
  206. </el-col>
  207. <el-col :xs="24" :sm="12" :lg="8">
  208. <el-form-item label="制单人" prop="createMan">
  209. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled />
  210. </el-form-item>
  211. </el-col>
  212. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  213. <el-form-item label="制单日期" prop="createDate">
  214. <el-date-picker
  215. v-model="mainForm.createDate"
  216. type="date"
  217. disabled
  218. value-format="yyyy-MM-dd"
  219. style="width: 100%"
  220. placeholder="选择日期"
  221. />
  222. </el-form-item>
  223. </el-col>
  224. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  225. <el-form-item label="合同有效期" prop="contractDate">
  226. <el-date-picker
  227. v-model="mainForm.contractDate"
  228. type="date"
  229. value-format="yyyy-MM-dd"
  230. style="width: 100%"
  231. placeholder="选择日期"
  232. />
  233. </el-form-item>
  234. </el-col>
  235. </el-row>
  236. </el-form>
  237. <div class="main-title">
  238. <div class="title">货品信息</div>
  239. <div>
  240. <el-button type="primary" size="mini" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  241. <el-divider direction="vertical" />
  242. <!-- <ImportButton :imUrl="'engin-info-order/import-item'" @importSuccess="getImportList" :isIcon="false" style="display: inline-block" />
  243. <ExportButton :exUrl="'engin-info-order/download'" :exParams="{}" :exText="'下载导入模版'" :isIcon="false" style="display: inline-block" /> -->
  244. </div>
  245. </div>
  246. <div class="table" style="margin-top: 20px">
  247. <el-table
  248. :data="goodsList"
  249. element-loading-text="Loading"
  250. border
  251. fit
  252. highlight-current-row
  253. stripe
  254. max-height="400"
  255. >
  256. <el-table-column align="center" label="序号" type="index" width="50" />
  257. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip>
  258. <template slot-scope="scope">
  259. <el-select
  260. v-if="listItem"
  261. v-model="scope.row.saleTypeId"
  262. placeholder="选择销售类型"
  263. size="mini"
  264. clearable
  265. style="width: 100%"
  266. @change="changeSaleType(scope.$index)"
  267. >
  268. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  269. </el-select>
  270. <div v-else>{{ scope.row.saleTypeName }}</div>
  271. </template>
  272. </el-table-column>
  273. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip />
  274. <el-table-column
  275. align="center"
  276. label="产品编码"
  277. prop="materialOldNumber"
  278. min-width="120"
  279. show-overflow-tooltip
  280. />
  281. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip />
  282. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  283. <template slot-scope="scope">
  284. <el-input v-if="listItem" v-model="scope.row.specification" size="mini" />
  285. <div v-else>{{ scope.row.specification }}</div>
  286. </template>
  287. </el-table-column>
  288. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip />
  289. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  290. <template slot-scope="scope">
  291. <el-input v-model="scope.row.price" size="small" type="number" @mousewheel.native.prevent />
  292. </template>
  293. </el-table-column>
  294. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  295. <template slot-scope="scope">
  296. <el-input v-model="scope.row.qty" size="small" type="number" @mousewheel.native.prevent />
  297. </template>
  298. </el-table-column>
  299. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  300. <template slot-scope="scope">
  301. {{ (scope.row.price || 0) * (scope.row.qty || 0) }}
  302. </template>
  303. </el-table-column>
  304. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  305. <template slot-scope="scope">
  306. <el-input v-model="scope.row.remark" size="small" />
  307. </template>
  308. </el-table-column>
  309. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip />
  310. <el-table-column align="center" label="操作" width="100" fixed="right">
  311. <template slot-scope="scope">
  312. <el-button type="text" @click="deleteItem(scope.$index, scope.row.cid)">删除</el-button>
  313. </template>
  314. </el-table-column>
  315. </el-table>
  316. </div>
  317. <div class="page-footer">
  318. <div class="footer">
  319. <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button>
  320. <!-- <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>-->
  321. <el-popconfirm title="确定关闭吗?" style="margin-left: 10px" @onConfirm="goBack">
  322. <el-button slot="reference">返回列表</el-button>
  323. </el-popconfirm>
  324. </div>
  325. </div>
  326. <el-dialog title="添加产品" :visible.sync="isShowGoodsDialog" width="80%">
  327. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  328. <el-row :gutter="20">
  329. <el-col :xs="12" :sm="6" :lg="6">
  330. <el-form-item prop="salesType">
  331. <el-select v-model="goodsScreenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  332. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  333. </el-select>
  334. </el-form-item>
  335. </el-col>
  336. <el-col :xs="12" :sm="6" :lg="6">
  337. <el-form-item prop="proNum">
  338. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码" />
  339. </el-form-item>
  340. </el-col>
  341. <el-col :xs="12" :sm="6" :lg="6">
  342. <el-form-item prop="proName">
  343. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称" />
  344. </el-form-item>
  345. </el-col>
  346. <el-col :xs="12" :sm="6" :lg="6">
  347. <el-form-item prop="proModel">
  348. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号" />
  349. </el-form-item>
  350. </el-col>
  351. <el-col :xs="12" :sm="6" :lg="6">
  352. <el-form-item prop="price1" style="display: flex">
  353. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%" />
  354. <span> - </span>
  355. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%" />
  356. </el-form-item>
  357. </el-col>
  358. <el-col :xs="12" :sm="18" :lg="18" class="tr">
  359. <el-form-item label="">
  360. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  361. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  362. </el-form-item>
  363. </el-col>
  364. </el-row>
  365. </el-form>
  366. <div class="tables">
  367. <div class="table">
  368. <el-table
  369. :data="leftGoodsList"
  370. element-loading-text="Loading"
  371. border
  372. fit
  373. highlight-current-row
  374. stripe
  375. height="400"
  376. @selection-change="leftSelectionChange"
  377. >
  378. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect" />
  379. <el-table-column align="center" label="销售类型" prop="saleName" show-overflow-tooltip />
  380. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  381. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  382. <el-table-column
  383. align="center"
  384. label="产品型号"
  385. prop="specification"
  386. min-width="160"
  387. show-overflow-tooltip
  388. />
  389. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  390. </el-table>
  391. <div class="pagination clearfix" style="margin-top: 10px">
  392. <div class="fr">
  393. <el-pagination
  394. :current-page="currentPage"
  395. :page-size="10"
  396. background
  397. layout="prev, pager, next"
  398. :total="listTotal"
  399. @current-change="handleTableCurrentChange"
  400. />
  401. </div>
  402. </div>
  403. </div>
  404. <div class="buttons">
  405. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  406. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  407. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  408. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  409. </div>
  410. <div class="table">
  411. <el-table
  412. :data="rightGoodsList"
  413. element-loading-text="Loading"
  414. border
  415. fit
  416. highlight-current-row
  417. stripe
  418. height="400"
  419. @selection-change="rightSelectionChange"
  420. >
  421. <el-table-column align="center" type="selection" width="55" />
  422. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  423. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  424. <el-table-column
  425. align="center"
  426. label="产品型号"
  427. prop="specification"
  428. min-width="160"
  429. show-overflow-tooltip
  430. />
  431. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  432. <el-table-column align="center" prop="saleName" label="销售类型" show-overflow-tooltip />
  433. </el-table>
  434. </div>
  435. </div>
  436. <span slot="footer" class="dialog-footer">
  437. <el-button @click="closeDialog">取 消</el-button>
  438. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  439. </span>
  440. </el-dialog>
  441. </div>
  442. </template>
  443. <script>
  444. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin } from '@/api/supply/engin'
  445. import { getDictList, getTypeList, getSalesmanList, getDealerList } from '@/api/common'
  446. export default {
  447. name: 'EnginForm',
  448. componentName: 'EnginForm',
  449. props: ['listItem'],
  450. data() {
  451. return {
  452. goodsList: [],
  453. mainForm: {
  454. orderNum: '',
  455. orderDate: '',
  456. // mainId: '102',
  457. jxsNum: '',
  458. enginName: '',
  459. machineType: '',
  460. jxsName: '',
  461. jxsId: '',
  462. company: '',
  463. address: '',
  464. enginNum: '',
  465. factoryNum: '',
  466. loginType: '',
  467. linkman: '',
  468. phone: '',
  469. tel: '',
  470. remark: '',
  471. salesMan: '',
  472. createMan: '',
  473. createDate: '',
  474. contractDate: '',
  475. tradeCategory: '',
  476. power: '',
  477. greeRemark: '',
  478. greeReply: '',
  479. fileNo: ''
  480. },
  481. mainFormRules: {
  482. salesMan: [{ required: true, message: '请选择业务员', trigger: 'change' }],
  483. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  484. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  485. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  486. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  487. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  488. enginNum: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
  489. loginType: [{ required: true, message: '请输入工程登录类型', trigger: 'blur' }],
  490. tradeCategory: [{ required: true, message: '请选择行业类别', trigger: 'change' }]
  491. },
  492. loginTypeList: [],
  493. powerList: [],
  494. machineTypeList: [],
  495. tradeCategoryList: [
  496. { value: '房地产', label: '房地产' },
  497. { value: '公共建筑', label: '公共建筑' },
  498. { value: '工业制造', label: '工业制造' },
  499. { value: '商业项目', label: '商业项目' },
  500. { value: '采暖及清洁能源', label: '采暖及清洁能源' },
  501. { value: '轨道交通', label: '轨道交通' },
  502. { value: '数据通讯', label: '数据通讯' },
  503. { value: '冷冻冷藏', label: '冷冻冷藏' },
  504. { value: '高端制造', label: '高端制造' },
  505. { value: '医院医疗', label: '医院医疗' },
  506. { value: '其他', label: '其他' }
  507. ],
  508. typeList: [],
  509. salesTypeList: [],
  510. salesmanList: [],
  511. dealerList: [],
  512. isShowGoodsDialog: false,
  513. goodsScreenForm: {
  514. proNum: '',
  515. proName: '',
  516. proModel: '',
  517. price1: '',
  518. price2: '',
  519. salesType: ''
  520. },
  521. currentPage: 1,
  522. listTotal: 0,
  523. leftGoodsList: [],
  524. rightGoodsList: [],
  525. leftSelection: [],
  526. rightSelection: [],
  527. examineStatus: ''
  528. }
  529. },
  530. computed: {
  531. isDealer() {
  532. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  533. }
  534. },
  535. async created() {
  536. await this.getSalesmanList()
  537. this.getDictList()
  538. this.getTypeList()
  539. this.getDealerList()
  540. if (this.listItem) {
  541. this.getDetail()
  542. } else {
  543. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  544. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  545. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  546. this.mainForm.createDate = this.getDate(0)
  547. this.mainForm.contractDate = this.getDate(1)
  548. }
  549. },
  550. methods: {
  551. // 返回列表
  552. goBack() {
  553. this.$emit('backListFormDetail')
  554. },
  555. getDate(addYear) {
  556. var date = new Date()
  557. var seperator1 = '-'
  558. var year = date.getFullYear() + addYear
  559. var month = date.getMonth() + 1
  560. var strDate = date.getDate()
  561. if (month >= 1 && month <= 9) {
  562. month = '0' + month
  563. }
  564. if (strDate >= 0 && strDate <= 9) {
  565. strDate = '0' + strDate
  566. }
  567. var currentdate = year + seperator1 + month + seperator1 + strDate
  568. return currentdate
  569. },
  570. // 获取详情
  571. getDetail() {
  572. getEnginDetail({ id: this.listItem.enginInfoId }).then(res => {
  573. const data = res.data
  574. this.mainForm.orderNum = data.enginInfoNo
  575. this.mainForm.orderDate = data.orderDate
  576. // this.mainForm.mainId = data.productCategoryId;
  577. this.mainForm.jxsNum = data.customerNumber
  578. this.mainForm.enginName = data.projectName
  579. this.mainForm.machineType = data.machineType
  580. this.mainForm.jxsName = data.customerName
  581. this.mainForm.company = data.useUnit
  582. this.mainForm.tradeCategory = data.tradeCategory
  583. this.mainForm.address = data.installAddress
  584. this.mainForm.enginNum = data.projectNo
  585. this.mainForm.factoryNum = data.enginFactoryNo
  586. this.mainForm.loginType = data.enginSignType
  587. this.mainForm.linkman = data.linkman
  588. this.mainForm.phone = data.phone
  589. this.mainForm.tel = data.tel
  590. this.mainForm.remark = data.remark
  591. this.mainForm.salesMan = data.serviceId
  592. this.mainForm.createMan = data.createName
  593. this.mainForm.createDate = data.createTime
  594. this.mainForm.contractDate = data.contractExpireDate
  595. this.mainForm.power = data.powerCategory
  596. this.mainForm.greeRemark = data.geLiInerNote
  597. this.mainForm.greeReply = data.geLiNote
  598. this.mainForm.fileNo = data.fileNo
  599. this.examineStatus = data.examineStatus
  600. data.items.forEach(item => {
  601. item.cantDel = true
  602. item.cid = item.id
  603. })
  604. this.goodsList = data.items
  605. })
  606. },
  607. // 获取经销商列表
  608. getDealerList() {
  609. getDealerList({
  610. pageNum: 1,
  611. pageSize: -1
  612. // bindUser: false
  613. }).then(res => {
  614. this.dealerList = res.data.records
  615. })
  616. },
  617. // 获取产品大类列表
  618. getDictList() {
  619. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  620. this.typeList = res.data
  621. })
  622. getDictList({ sysDictEnum: 'MACHINE_TYPE' }).then(res => {
  623. this.machineTypeList = res.data
  624. })
  625. getDictList({ sysDictEnum: 'POWER_CATEGORY' }).then(res => {
  626. this.powerList = res.data
  627. })
  628. getDictList({ sysDictEnum: 'SIGN_TYPE' }).then(res => {
  629. this.loginTypeList = res.data
  630. })
  631. },
  632. // 获取销售类型列表
  633. getTypeList() {
  634. getTypeList({
  635. pageNum: 1,
  636. pageSize: -1
  637. }).then(res => {
  638. this.salesTypeList = res.data.records
  639. })
  640. },
  641. async getSalesmanList() {
  642. const res = await getSalesmanList({
  643. pageNum: 1,
  644. pageSize: -1,
  645. isCustomer: 0,
  646. status: true
  647. })
  648. this.salesmanList = res.data.records
  649. },
  650. changeDealer() {
  651. if (this.mainForm.jxsNum) {
  652. const jxsItem = this.dealerList.find(o => o.number == this.mainForm.jxsNum)
  653. this.mainForm.jxsName = jxsItem.name
  654. this.mainForm.jxsId = jxsItem.id
  655. } else {
  656. this.mainForm.jxsName = ''
  657. this.mainForm.jxsId = ''
  658. }
  659. },
  660. changeSaleType(index) {
  661. if (this.goodsList[index].saleTypeId) {
  662. const obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId)
  663. this.goodsList[index].saleTypeName = obj.saleName
  664. this.goodsList[index].saleTypeCode = obj.saleCode
  665. } else {
  666. this.goodsList[index].saleTypeName = ''
  667. this.goodsList[index].saleTypeCode = ''
  668. }
  669. },
  670. // 获取商品列表
  671. getGoodsList() {
  672. getRetailProductList({
  673. pageNum: this.currentPage,
  674. pageSize: 10,
  675. saleId: this.goodsScreenForm.salesType,
  676. materialCode: this.goodsScreenForm.proNum,
  677. materialName: this.goodsScreenForm.proName,
  678. specification: this.goodsScreenForm.proModel,
  679. price1: this.goodsScreenForm.price1,
  680. price2: this.goodsScreenForm.price2,
  681. customerId: this.listItem ? this.listItem.customerId : ''
  682. }).then(res => {
  683. const oldGoodsList = this.goodsList
  684. const newGoodsList = res.data.records
  685. for (let i = 0; i < oldGoodsList.length; i++) {
  686. const oldItem = oldGoodsList[i]
  687. for (let j = 0; j < newGoodsList.length; j++) {
  688. const newItem = newGoodsList[j]
  689. if (newItem.id === oldItem.id) {
  690. newGoodsList[j].selected = true
  691. break
  692. }
  693. }
  694. }
  695. res.data.records.forEach(item => {
  696. item.materialName = item.name
  697. item.materialCode = item.number
  698. item.saleTypeName = item.saleName
  699. item.unit = item.baseUnit
  700. item.price = item.batchPrice
  701. item.tax = item.taxRate
  702. item.isDirectTransfer = false
  703. item.directTransferQty = ''
  704. item.status1 = ''
  705. item.status2 = ''
  706. item.rebateAmount = ''
  707. item.rebateRate = ''
  708. item.productPriceId = item.id
  709. // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  710. })
  711. this.leftGoodsList = res.data.records
  712. this.listTotal = res.data.total
  713. })
  714. },
  715. // 查询重复值并禁选
  716. checkboxSelect(row, rowIndex) {
  717. if (row.selected) {
  718. return false // 禁用
  719. } else {
  720. return true // 不禁用
  721. }
  722. },
  723. // 点击 选择商品
  724. openDialog() {
  725. this.isShowGoodsDialog = true
  726. this.getGoodsList()
  727. },
  728. // 提交筛选表单
  729. submitGoodsScreenForm() {
  730. this.currentPage = 1
  731. this.getGoodsList()
  732. },
  733. // 重置筛选表单
  734. resetGoodsScreenForm() {
  735. this.$refs.goodsScreenForm.resetFields()
  736. this.currentPage = 1
  737. this.getGoodsList()
  738. },
  739. // 更改列表当前页
  740. handleTableCurrentChange(val) {
  741. this.currentPage = val
  742. this.getGoodsList()
  743. },
  744. // 关闭 弹窗
  745. closeDialog() {
  746. this.isShowGoodsDialog = false
  747. },
  748. // 左侧列表选择
  749. leftSelectionChange(val) {
  750. this.leftSelection = val
  751. },
  752. // 右侧列表选择
  753. rightSelectionChange(val) {
  754. this.rightSelection = val
  755. },
  756. // 数组去重
  757. delRepeat(arr1, arr2) {
  758. const allArr = arr1.concat(arr2) // 两个数组对象合并
  759. const newArr = [] // 存放去重后数据的新数组
  760. for (let i = 0; i < allArr.length; i++) {
  761. // 循环allArr数组对象的内容
  762. let flag = true // 建立标记,判断数据是否重复,true为不重复
  763. for (let j = 0; j < newArr.length; j++) {
  764. // 循环新数组的内容
  765. if (allArr[i].id == newArr[j].id) {
  766. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  767. flag = false
  768. }
  769. }
  770. if (flag) {
  771. // 判断是否重复
  772. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  773. }
  774. }
  775. return newArr
  776. },
  777. // 全部添加
  778. addAllGoods() {
  779. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  780. },
  781. // 添加
  782. addGoods() {
  783. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  784. },
  785. // 删除
  786. deleteGoods() {
  787. const rightGoodsList = this.rightGoodsList
  788. const rightSelection = this.rightSelection
  789. for (let i = 0; i < rightGoodsList.length; i++) {
  790. for (let j = 0; j < rightSelection.length; j++) {
  791. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  792. this.rightGoodsList.splice(i, 1)
  793. }
  794. }
  795. }
  796. },
  797. // 全部删除
  798. deleteAllGoods() {
  799. this.rightGoodsList = []
  800. },
  801. // 确定 添加产品
  802. submitAddGoods() {
  803. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  804. this.goodsList = this.goodsList.concat(this.rightGoodsList)
  805. this.goodsList.forEach(k => {
  806. k.cid = ''
  807. })
  808. this.isShowGoodsDialog = false
  809. this.leftGoodsList = []
  810. this.rightGoodsList = []
  811. },
  812. // 删除产品
  813. deleteItem(index, id) {
  814. if (this.listItem && this.examineStatus === 'OK' && id) {
  815. this.$errorMsg('已审核通过的型号不能删除')
  816. return
  817. }
  818. this.goodsList.splice(index, 1)
  819. },
  820. // 导入产品
  821. getImportList(data) {
  822. this.goodsList = this.goodsList.concat(data)
  823. },
  824. clickSubmitForm(type) {
  825. this.$refs.mainForm.validate(valid => {
  826. if (valid) {
  827. for (let i = 0; i < this.goodsList.length; i++) {
  828. if (!this.goodsList[i].saleTypeId) {
  829. this.$errorMsg('请选择销售类型')
  830. return
  831. }
  832. if (!Number(this.goodsList[i].qty)) {
  833. this.$errorMsg('不允许数量为0')
  834. return
  835. }
  836. if (!this.goodsList[i].materialNumber) {
  837. return
  838. }
  839. }
  840. const goodsList = JSON.parse(JSON.stringify(this.goodsList))
  841. goodsList.forEach(item => {
  842. delete item.productList
  843. delete item.id
  844. })
  845. const saleManItem = this.mainForm.salesMan
  846. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  847. : ''
  848. const params = {
  849. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  850. // mainId: this.mainForm.mainId,
  851. projectName: this.mainForm.enginName,
  852. machineType: this.mainForm.machineType,
  853. useUnit: this.mainForm.company,
  854. tradeCategory: this.mainForm.tradeCategory,
  855. installAddress: this.mainForm.address,
  856. projectNo: this.mainForm.enginNum,
  857. enginFactoryNo: this.mainForm.factoryNum,
  858. enginSignType: this.mainForm.loginType,
  859. linkman: this.mainForm.linkman,
  860. phone: this.mainForm.phone,
  861. serviceId: this.mainForm.salesMan,
  862. serviceName: saleManItem.nickName,
  863. tel: this.mainForm.tel,
  864. remark: this.mainForm.remark,
  865. contractExpireDate: this.mainForm.contractDate,
  866. powerCategory: this.mainForm.power,
  867. geLiInerNote: this.mainForm.greeRemark,
  868. geLiNote: this.mainForm.greeReply,
  869. fileNo: this.mainForm.fileNo,
  870. items: goodsList
  871. }
  872. if (type === 1) {
  873. if (this.listItem) {
  874. params.enginInfoId = this.listItem.enginInfoId
  875. editEngin(params).then(res => {
  876. this.$successMsg('编辑成功')
  877. this.goBack()
  878. this.$parent.getList()
  879. })
  880. } else {
  881. params.customerNumber = this.mainForm.jxsNum
  882. params.customerName = this.mainForm.jxsName
  883. params.customerId = this.mainForm.jxsId
  884. addEngin(params).then(res => {
  885. this.$successMsg('保存成功')
  886. this.goBack()
  887. this.$parent.getList()
  888. })
  889. }
  890. } else {
  891. if (this.listItem) {
  892. params.enginInfoId = this.listItem.enginInfoId
  893. } else {
  894. params.customerNumber = this.mainForm.jxsNum
  895. params.customerName = this.mainForm.jxsName
  896. params.customerId = this.mainForm.jxsId
  897. }
  898. submitEngin(params).then(res => {
  899. this.$successMsg('提交审核成功')
  900. this.goBack()
  901. this.$parent.getList()
  902. })
  903. }
  904. }
  905. })
  906. }
  907. }
  908. }
  909. </script>
  910. <style scoped lang="scss">
  911. .detail-container {
  912. width: 100%;
  913. height: 100%;
  914. }
  915. .main-title {
  916. display: flex;
  917. justify-content: space-between;
  918. align-items: center;
  919. margin-top: 20px;
  920. height: 60px;
  921. border-bottom: 1px solid #dcdfe6;
  922. margin-bottom: 20px;
  923. .title {
  924. font-size: 16px;
  925. font-weight: 600;
  926. padding-left: 10px;
  927. }
  928. }
  929. .tables {
  930. display: flex;
  931. margin-top: 10px;
  932. .table {
  933. width: 45%;
  934. }
  935. .buttons {
  936. display: flex;
  937. flex-direction: column;
  938. justify-content: center;
  939. align-items: center;
  940. padding: 0 10px;
  941. button {
  942. margin: 0;
  943. margin-top: 10px;
  944. }
  945. }
  946. }
  947. ::v-deep input::-webkit-outer-spin-button,
  948. ::v-deep input::-webkit-inner-spin-button {
  949. -webkit-appearance: none;
  950. }
  951. ::v-deep input[type='number'] {
  952. -moz-appearance: textfield;
  953. }
  954. </style>