engin_form.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  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. show-summary
  255. :summary-method="$getSummaries"
  256. max-height="400"
  257. >
  258. <el-table-column align="center" label="序号" type="index" width="50" />
  259. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip>
  260. <template slot-scope="scope">
  261. <el-select
  262. v-if="listItem"
  263. v-model="scope.row.saleTypeId"
  264. placeholder="选择销售类型"
  265. size="mini"
  266. clearable
  267. style="width: 100%"
  268. @change="changeSaleType(scope.$index)"
  269. >
  270. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  271. </el-select>
  272. <div v-else>{{ scope.row.saleTypeName }}</div>
  273. </template>
  274. </el-table-column>
  275. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip />
  276. <el-table-column
  277. align="center"
  278. label="产品编码"
  279. prop="materialOldNumber"
  280. min-width="120"
  281. show-overflow-tooltip
  282. />
  283. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip />
  284. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  285. <template slot-scope="scope">
  286. <el-input v-if="listItem" v-model="scope.row.specification" size="mini" />
  287. <div v-else>{{ scope.row.specification }}</div>
  288. </template>
  289. </el-table-column>
  290. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip />
  291. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  292. <template slot-scope="scope">
  293. <el-input v-model="scope.row.price" size="small" type="number" @mousewheel.native.prevent />
  294. </template>
  295. </el-table-column>
  296. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  297. <template slot-scope="scope">
  298. <el-input v-model.number="scope.row.qty" size="small" type="number" @mousewheel.native.prevent />
  299. </template>
  300. </el-table-column>
  301. <el-table-column align="center" label="订单金额" prop="myTotalAmount" min-width="100" show-overflow-tooltip>
  302. <template slot-scope="scope">
  303. {{ (scope.row.price || 0) * (scope.row.qty || 0) }}
  304. </template>
  305. </el-table-column>
  306. <el-table-column align="center" label="备注" prop="remark" min-width="200" show-overflow-tooltip>
  307. <template slot-scope="scope">
  308. <el-input v-model="scope.row.remark" size="small" />
  309. </template>
  310. </el-table-column>
  311. <el-table-column align="center" label="税率" prop="taxRate" min-width="100" show-overflow-tooltip />
  312. <el-table-column align="center" label="操作" width="100" fixed="right">
  313. <template slot-scope="scope">
  314. <el-button type="text" @click="deleteItem(scope.$index, scope.row, scope.row.cid)">删除</el-button>
  315. </template>
  316. </el-table-column>
  317. </el-table>
  318. </div>
  319. <div class="page-footer">
  320. <div class="footer">
  321. <el-button type="primary" :loading="btnLoading" @click="clickSubmitForm(1)">保 存</el-button>
  322. <!-- <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>-->
  323. <el-popconfirm title="确定关闭吗?" style="margin-left: 10px" @onConfirm="goBack">
  324. <el-button slot="reference">返回列表</el-button>
  325. </el-popconfirm>
  326. </div>
  327. </div>
  328. <el-dialog
  329. title="添加产品"
  330. :modal-append-to-body="true"
  331. :append-to-body="true"
  332. :visible.sync="isShowGoodsDialog"
  333. width="80%"
  334. >
  335. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  336. <el-row :gutter="20">
  337. <el-col :xs="12" :sm="6" :lg="6">
  338. <el-form-item prop="salesType">
  339. <el-select v-model="goodsScreenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  340. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id" />
  341. </el-select>
  342. </el-form-item>
  343. </el-col>
  344. <el-col :xs="12" :sm="6" :lg="6">
  345. <el-form-item prop="proNum">
  346. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码" />
  347. </el-form-item>
  348. </el-col>
  349. <el-col :xs="12" :sm="6" :lg="6">
  350. <el-form-item prop="proName">
  351. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称" />
  352. </el-form-item>
  353. </el-col>
  354. <el-col :xs="12" :sm="6" :lg="6">
  355. <el-form-item prop="proModel">
  356. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号" />
  357. </el-form-item>
  358. </el-col>
  359. <el-col :xs="12" :sm="6" :lg="6">
  360. <el-form-item prop="price1" style="display: flex">
  361. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%" />
  362. <span> - </span>
  363. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%" />
  364. </el-form-item>
  365. </el-col>
  366. <el-col :xs="12" :sm="18" :lg="18" class="tr">
  367. <el-form-item label="">
  368. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  369. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  370. </el-form-item>
  371. </el-col>
  372. </el-row>
  373. </el-form>
  374. <div class="tables">
  375. <div class="table">
  376. <el-table
  377. :data="leftGoodsList"
  378. element-loading-text="Loading"
  379. border
  380. fit
  381. highlight-current-row
  382. stripe
  383. height="400"
  384. @selection-change="leftSelectionChange"
  385. >
  386. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect" />
  387. <el-table-column align="center" label="销售类型" prop="saleName" show-overflow-tooltip />
  388. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  389. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  390. <el-table-column
  391. align="center"
  392. label="产品型号"
  393. prop="specification"
  394. min-width="160"
  395. show-overflow-tooltip
  396. />
  397. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  398. </el-table>
  399. <div class="pagination clearfix" style="margin-top: 10px">
  400. <div class="fr">
  401. <el-pagination
  402. :current-page="currentPage"
  403. :page-size="10"
  404. background
  405. layout="prev, pager, next"
  406. :total="listTotal"
  407. @current-change="handleTableCurrentChange"
  408. />
  409. </div>
  410. </div>
  411. </div>
  412. <div class="buttons">
  413. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  414. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  415. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  416. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  417. </div>
  418. <div class="table">
  419. <el-table
  420. :data="rightGoodsList"
  421. element-loading-text="Loading"
  422. border
  423. fit
  424. highlight-current-row
  425. stripe
  426. height="400"
  427. @selection-change="rightSelectionChange"
  428. >
  429. <el-table-column align="center" type="selection" width="55" />
  430. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip />
  431. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip />
  432. <el-table-column
  433. align="center"
  434. label="产品型号"
  435. prop="specification"
  436. min-width="160"
  437. show-overflow-tooltip
  438. />
  439. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip />
  440. <el-table-column align="center" prop="saleName" label="销售类型" show-overflow-tooltip />
  441. </el-table>
  442. </div>
  443. </div>
  444. <span slot="footer" class="dialog-footer">
  445. <el-button @click="closeDialog">取 消</el-button>
  446. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  447. </span>
  448. </el-dialog>
  449. </div>
  450. </template>
  451. <script>
  452. import { getEnginDetail, getRetailProductList, addEngin, editEngin, submitEngin, delItem } from '@/api/supply/engin'
  453. import { getDictList, getTypeList, getSalesmanList, getDealerList } from '@/api/common'
  454. export default {
  455. name: 'EnginForm',
  456. componentName: 'EnginForm',
  457. props: ['listItem'],
  458. data() {
  459. return {
  460. goodsList: [],
  461. mainForm: {
  462. orderNum: '',
  463. orderDate: '',
  464. // mainId: '102',
  465. jxsNum: '',
  466. enginName: '',
  467. machineType: '',
  468. jxsName: '',
  469. jxsId: '',
  470. company: '',
  471. address: '',
  472. enginNum: '',
  473. factoryNum: '',
  474. loginType: '',
  475. linkman: '',
  476. phone: '',
  477. tel: '',
  478. remark: '',
  479. salesMan: '',
  480. createMan: '',
  481. createDate: '',
  482. contractDate: '',
  483. tradeCategory: '',
  484. power: '',
  485. greeRemark: '',
  486. greeReply: '',
  487. fileNo: ''
  488. },
  489. mainFormRules: {
  490. salesMan: [{ required: true, message: '请选择业务员', trigger: 'change' }],
  491. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  492. enginName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
  493. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  494. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  495. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  496. enginNum: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
  497. loginType: [{ required: true, message: '请输入工程登录类型', trigger: 'blur' }],
  498. tradeCategory: [{ required: true, message: '请选择行业类别', trigger: 'change' }]
  499. },
  500. loginTypeList: [],
  501. powerList: [],
  502. machineTypeList: [],
  503. tradeCategoryList: [
  504. { value: '房地产', label: '房地产' },
  505. { value: '公共建筑', label: '公共建筑' },
  506. { value: '工业制造', label: '工业制造' },
  507. { value: '商业项目', label: '商业项目' },
  508. { value: '采暖及清洁能源', label: '采暖及清洁能源' },
  509. { value: '轨道交通', label: '轨道交通' },
  510. { value: '数据通讯', label: '数据通讯' },
  511. { value: '冷冻冷藏', label: '冷冻冷藏' },
  512. { value: '高端制造', label: '高端制造' },
  513. { value: '医院医疗', label: '医院医疗' },
  514. { value: '其他', label: '其他' }
  515. ],
  516. btnLoading: false,
  517. typeList: [],
  518. salesTypeList: [],
  519. salesmanList: [],
  520. dealerList: [],
  521. isShowGoodsDialog: false,
  522. goodsScreenForm: {
  523. proNum: '',
  524. proName: '',
  525. proModel: '',
  526. price1: '',
  527. price2: '',
  528. salesType: ''
  529. },
  530. currentPage: 1,
  531. listTotal: 0,
  532. leftGoodsList: [],
  533. rightGoodsList: [],
  534. leftSelection: [],
  535. rightSelection: [],
  536. examineStatus: ''
  537. }
  538. },
  539. computed: {
  540. isDealer() {
  541. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  542. }
  543. },
  544. watch: {
  545. goodsList: {
  546. deep: true,
  547. immediate: true,
  548. handler(val, oval) {
  549. val.forEach(item => {
  550. item.myTotalAmount = (item.price || 0) * (item.qty || 0)
  551. item.sums1 = ['number', 'directTransferQty', 'qty', 'enginNum', 'oldQty', 'hasSendQty']
  552. item.sums2 = ['myTotalAmount', 'payAmount', 'price', 'payRebateAmount', 'discAmount']
  553. })
  554. }
  555. }
  556. },
  557. async created() {
  558. await this.getSalesmanList()
  559. this.getDictList()
  560. this.getTypeList()
  561. this.getDealerList()
  562. if (this.listItem) {
  563. this.getDetail()
  564. } else {
  565. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  566. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  567. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  568. this.mainForm.createDate = this.getDate(0)
  569. this.mainForm.contractDate = this.getDate(1)
  570. }
  571. },
  572. methods: {
  573. // 返回列表
  574. goBack() {
  575. this.$emit('backListFormDetail')
  576. },
  577. getDate(addYear) {
  578. var date = new Date()
  579. var seperator1 = '-'
  580. var year = date.getFullYear() + addYear
  581. var month = date.getMonth() + 1
  582. var strDate = date.getDate()
  583. if (month >= 1 && month <= 9) {
  584. month = '0' + month
  585. }
  586. if (strDate >= 0 && strDate <= 9) {
  587. strDate = '0' + strDate
  588. }
  589. var currentdate = year + seperator1 + month + seperator1 + strDate
  590. return currentdate
  591. },
  592. // 获取详情
  593. getDetail() {
  594. getEnginDetail({ id: this.listItem.enginInfoId }).then(res => {
  595. const data = res.data
  596. this.mainForm.orderNum = data.enginInfoNo
  597. this.mainForm.orderDate = data.orderDate
  598. // this.mainForm.mainId = data.productCategoryId;
  599. this.mainForm.jxsNum = data.customerNumber
  600. this.mainForm.enginName = data.projectName
  601. this.mainForm.machineType = data.machineType
  602. this.mainForm.jxsName = data.customerName
  603. this.mainForm.company = data.useUnit
  604. this.mainForm.tradeCategory = data.tradeCategory
  605. this.mainForm.address = data.installAddress
  606. this.mainForm.enginNum = data.projectNo
  607. this.mainForm.factoryNum = data.enginFactoryNo
  608. this.mainForm.loginType = data.enginSignType
  609. this.mainForm.linkman = data.linkman
  610. this.mainForm.phone = data.phone
  611. this.mainForm.tel = data.tel
  612. this.mainForm.remark = data.remark
  613. this.mainForm.salesMan = data.serviceId
  614. this.mainForm.createMan = data.createName
  615. this.mainForm.createDate = data.createTime
  616. this.mainForm.contractDate = data.contractExpireDate
  617. this.mainForm.power = data.powerCategory
  618. this.mainForm.greeRemark = data.geLiInerNote
  619. this.mainForm.greeReply = data.geLiNote
  620. this.mainForm.fileNo = data.fileNo
  621. this.examineStatus = data.examineStatus
  622. data.items.forEach(item => {
  623. item.cantDel = true
  624. item.cid = item.id
  625. })
  626. this.goodsList = data.items
  627. })
  628. },
  629. // 获取经销商列表
  630. getDealerList() {
  631. getDealerList({
  632. pageNum: 1,
  633. pageSize: -1
  634. // bindUser: false
  635. }).then(res => {
  636. this.dealerList = res.data.records
  637. })
  638. },
  639. // 获取产品大类列表
  640. getDictList() {
  641. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  642. this.typeList = res.data
  643. })
  644. getDictList({ sysDictEnum: 'MACHINE_TYPE' }).then(res => {
  645. this.machineTypeList = res.data
  646. })
  647. getDictList({ sysDictEnum: 'POWER_CATEGORY' }).then(res => {
  648. this.powerList = res.data
  649. })
  650. getDictList({ sysDictEnum: 'SIGN_TYPE' }).then(res => {
  651. this.loginTypeList = res.data
  652. })
  653. },
  654. // 获取销售类型列表
  655. getTypeList() {
  656. getTypeList({
  657. pageNum: 1,
  658. pageSize: -1
  659. }).then(res => {
  660. this.salesTypeList = res.data.records
  661. })
  662. },
  663. async getSalesmanList() {
  664. const res = await getSalesmanList({
  665. pageNum: 1,
  666. pageSize: -1,
  667. isCustomer: 0,
  668. status: true
  669. })
  670. this.salesmanList = res.data.records
  671. },
  672. changeDealer() {
  673. if (this.mainForm.jxsNum) {
  674. const jxsItem = this.dealerList.find(o => o.number == this.mainForm.jxsNum)
  675. this.mainForm.jxsName = jxsItem.name
  676. this.mainForm.jxsId = jxsItem.id
  677. } else {
  678. this.mainForm.jxsName = ''
  679. this.mainForm.jxsId = ''
  680. }
  681. },
  682. changeSaleType(index) {
  683. if (this.goodsList[index].saleTypeId) {
  684. const obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId)
  685. this.goodsList[index].saleTypeName = obj.saleName
  686. this.goodsList[index].saleTypeCode = obj.saleCode
  687. } else {
  688. this.goodsList[index].saleTypeName = ''
  689. this.goodsList[index].saleTypeCode = ''
  690. }
  691. },
  692. // 获取商品列表
  693. getGoodsList() {
  694. getRetailProductList({
  695. pageNum: this.currentPage,
  696. pageSize: 10,
  697. saleId: this.goodsScreenForm.salesType,
  698. materialCode: this.goodsScreenForm.proNum,
  699. materialName: this.goodsScreenForm.proName,
  700. specification: this.goodsScreenForm.proModel,
  701. price1: this.goodsScreenForm.price1,
  702. price2: this.goodsScreenForm.price2,
  703. customerId: this.listItem ? this.listItem.customerId : ''
  704. }).then(res => {
  705. const oldGoodsList = this.goodsList
  706. const newGoodsList = res.data.records
  707. for (let i = 0; i < oldGoodsList.length; i++) {
  708. const oldItem = oldGoodsList[i]
  709. for (let j = 0; j < newGoodsList.length; j++) {
  710. const newItem = newGoodsList[j]
  711. if (newItem.id === oldItem.id) {
  712. newGoodsList[j].selected = true
  713. break
  714. }
  715. }
  716. }
  717. res.data.records.forEach(item => {
  718. item.materialName = item.name
  719. item.materialCode = item.number
  720. item.saleTypeName = item.saleName
  721. item.unit = item.baseUnit
  722. item.price = item.batchPrice
  723. item.tax = item.taxRate
  724. item.isDirectTransfer = false
  725. item.directTransferQty = ''
  726. item.status1 = ''
  727. item.status2 = ''
  728. item.rebateAmount = ''
  729. item.rebateRate = ''
  730. item.productPriceId = item.id
  731. // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  732. })
  733. this.leftGoodsList = res.data.records
  734. this.listTotal = res.data.total
  735. })
  736. },
  737. // 查询重复值并禁选
  738. checkboxSelect(row, rowIndex) {
  739. if (row.selected) {
  740. return false // 禁用
  741. } else {
  742. return true // 不禁用
  743. }
  744. },
  745. // 点击 选择商品
  746. openDialog() {
  747. this.isShowGoodsDialog = true
  748. this.getGoodsList()
  749. },
  750. // 提交筛选表单
  751. submitGoodsScreenForm() {
  752. this.currentPage = 1
  753. this.getGoodsList()
  754. },
  755. // 重置筛选表单
  756. resetGoodsScreenForm() {
  757. this.$refs.goodsScreenForm.resetFields()
  758. this.currentPage = 1
  759. this.getGoodsList()
  760. },
  761. // 更改列表当前页
  762. handleTableCurrentChange(val) {
  763. this.currentPage = val
  764. this.getGoodsList()
  765. },
  766. // 关闭 弹窗
  767. closeDialog() {
  768. this.isShowGoodsDialog = false
  769. },
  770. // 左侧列表选择
  771. leftSelectionChange(val) {
  772. this.leftSelection = val
  773. },
  774. // 右侧列表选择
  775. rightSelectionChange(val) {
  776. this.rightSelection = val
  777. },
  778. // 数组去重
  779. delRepeat(arr1, arr2) {
  780. const allArr = arr1.concat(arr2) // 两个数组对象合并
  781. const newArr = [] // 存放去重后数据的新数组
  782. for (let i = 0; i < allArr.length; i++) {
  783. // 循环allArr数组对象的内容
  784. let flag = true // 建立标记,判断数据是否重复,true为不重复
  785. for (let j = 0; j < newArr.length; j++) {
  786. // 循环新数组的内容
  787. if (allArr[i].id == newArr[j].id) {
  788. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  789. flag = false
  790. }
  791. }
  792. if (flag) {
  793. // 判断是否重复
  794. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  795. }
  796. }
  797. return newArr
  798. },
  799. // 全部添加
  800. addAllGoods() {
  801. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  802. },
  803. // 添加
  804. addGoods() {
  805. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  806. },
  807. // 删除
  808. deleteGoods() {
  809. const rightGoodsList = this.rightGoodsList
  810. const rightSelection = this.rightSelection
  811. for (let i = 0; i < rightGoodsList.length; i++) {
  812. for (let j = 0; j < rightSelection.length; j++) {
  813. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  814. this.rightGoodsList.splice(i, 1)
  815. }
  816. }
  817. }
  818. },
  819. // 全部删除
  820. deleteAllGoods() {
  821. this.rightGoodsList = []
  822. },
  823. // 确定 添加产品
  824. submitAddGoods() {
  825. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  826. this.goodsList = this.goodsList.concat(this.rightGoodsList)
  827. this.goodsList.forEach(k => {
  828. if (!k.qty) {
  829. k.qty = 0
  830. }
  831. if (!k.cid) {
  832. k.cid = ''
  833. }
  834. })
  835. this.isShowGoodsDialog = false
  836. this.leftGoodsList = []
  837. this.rightGoodsList = []
  838. },
  839. // 删除产品
  840. deleteItem(index, row, id) {
  841. // id id存在就说明这个货品已经引用过了
  842. // if (this.listItem && this.examineStatus === 'OK' && id) {
  843. // this.$errorMsg('已审核通过的型号不能删除')
  844. // return
  845. // }
  846. if (id) {
  847. delItem({
  848. enginInfoNo: row.enginInfoNo,
  849. itemId: row.id
  850. }).then(res => {
  851. this.goodsList.splice(index, 1)
  852. this.$successMsg('存在的货品删除成功')
  853. })
  854. } else {
  855. this.goodsList.splice(index, 1)
  856. this.$successMsg('删除成功')
  857. }
  858. },
  859. // 导入产品
  860. getImportList(data) {
  861. this.goodsList = this.goodsList.concat(data)
  862. },
  863. clickSubmitForm(type) {
  864. this.btnLoading = true
  865. this.$refs.mainForm.validate(valid => {
  866. if (valid) {
  867. for (let i = 0; i < this.goodsList.length; i++) {
  868. if (!this.goodsList[i].saleTypeId) {
  869. this.$errorMsg('请选择销售类型')
  870. return
  871. }
  872. console.log(this.goodsList[i].qty)
  873. if (this.goodsList[i].qty == null || this.goodsList[i].qty === '' || Number(this.goodsList[i].qty) < 0) {
  874. this.$errorMsg('数量不能为空或者小于0')
  875. return
  876. }
  877. if (!this.goodsList[i].materialNumber) {
  878. return
  879. }
  880. }
  881. const goodsList = JSON.parse(JSON.stringify(this.goodsList))
  882. goodsList.forEach(item => {
  883. delete item.productList
  884. delete item.id
  885. })
  886. const saleManItem = this.mainForm.salesMan
  887. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  888. : ''
  889. const params = {
  890. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  891. // mainId: this.mainForm.mainId,
  892. projectName: this.mainForm.enginName,
  893. machineType: this.mainForm.machineType,
  894. useUnit: this.mainForm.company,
  895. tradeCategory: this.mainForm.tradeCategory,
  896. installAddress: this.mainForm.address,
  897. projectNo: this.mainForm.enginNum,
  898. enginFactoryNo: this.mainForm.factoryNum,
  899. enginSignType: this.mainForm.loginType,
  900. linkman: this.mainForm.linkman,
  901. phone: this.mainForm.phone,
  902. serviceId: this.mainForm.salesMan,
  903. serviceName: saleManItem.nickName,
  904. tel: this.mainForm.tel,
  905. remark: this.mainForm.remark,
  906. contractExpireDate: this.mainForm.contractDate,
  907. powerCategory: this.mainForm.power,
  908. geLiInerNote: this.mainForm.greeRemark,
  909. geLiNote: this.mainForm.greeReply,
  910. fileNo: this.mainForm.fileNo,
  911. items: goodsList
  912. }
  913. console.log(params)
  914. if (type === 1) {
  915. if (this.listItem) {
  916. params.enginInfoId = this.listItem.enginInfoId
  917. editEngin(params).then(res => {
  918. this.btnLoading = false
  919. this.$successMsg('编辑成功')
  920. this.goBack()
  921. })
  922. } else {
  923. params.customerNumber = this.mainForm.jxsNum
  924. params.customerName = this.mainForm.jxsName
  925. params.customerId = this.mainForm.jxsId
  926. addEngin(params).then(res => {
  927. this.$successMsg('保存成功')
  928. this.btnLoading = false
  929. this.goBack()
  930. })
  931. }
  932. } else {
  933. if (this.listItem) {
  934. params.enginInfoId = this.listItem.enginInfoId
  935. } else {
  936. params.customerNumber = this.mainForm.jxsNum
  937. params.customerName = this.mainForm.jxsName
  938. params.customerId = this.mainForm.jxsId
  939. }
  940. submitEngin(params).then(res => {
  941. this.$successMsg('提交审核成功')
  942. this.goBack()
  943. })
  944. }
  945. }
  946. })
  947. }
  948. }
  949. }
  950. </script>
  951. <style scoped lang="scss">
  952. .detail-container {
  953. width: 100%;
  954. height: 100%;
  955. }
  956. .main-title {
  957. display: flex;
  958. justify-content: space-between;
  959. align-items: center;
  960. margin-top: 20px;
  961. height: 60px;
  962. border-bottom: 1px solid #dcdfe6;
  963. margin-bottom: 20px;
  964. .title {
  965. font-size: 16px;
  966. font-weight: 600;
  967. padding-left: 10px;
  968. }
  969. }
  970. .tables {
  971. display: flex;
  972. margin-top: 10px;
  973. .table {
  974. width: 45%;
  975. }
  976. .buttons {
  977. display: flex;
  978. flex-direction: column;
  979. justify-content: center;
  980. align-items: center;
  981. padding: 0 10px;
  982. button {
  983. margin: 0;
  984. margin-top: 10px;
  985. }
  986. }
  987. }
  988. ::v-deep input::-webkit-outer-spin-button,
  989. ::v-deep input::-webkit-inner-spin-button {
  990. -webkit-appearance: none;
  991. }
  992. ::v-deep input[type='number'] {
  993. -moz-appearance: textfield;
  994. }
  995. </style>