engin_form.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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" @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. typeList: [],
  517. salesTypeList: [],
  518. salesmanList: [],
  519. dealerList: [],
  520. isShowGoodsDialog: false,
  521. goodsScreenForm: {
  522. proNum: '',
  523. proName: '',
  524. proModel: '',
  525. price1: '',
  526. price2: '',
  527. salesType: ''
  528. },
  529. currentPage: 1,
  530. listTotal: 0,
  531. leftGoodsList: [],
  532. rightGoodsList: [],
  533. leftSelection: [],
  534. rightSelection: [],
  535. examineStatus: ''
  536. }
  537. },
  538. computed: {
  539. isDealer() {
  540. return JSON.parse(localStorage.getItem('supply_user')).isCustomer
  541. }
  542. },
  543. watch: {
  544. goodsList: {
  545. deep: true,
  546. immediate: true,
  547. handler(val, oval) {
  548. val.forEach(item => {
  549. item.myTotalAmount = (item.price || 0) * (item.qty || 0)
  550. item.sums1 = ['number', 'directTransferQty', 'qty', 'enginNum', 'oldQty', 'hasSendQty']
  551. item.sums2 = ['myTotalAmount', 'payAmount', 'price', 'payRebateAmount', 'discAmount']
  552. })
  553. }
  554. }
  555. },
  556. async created() {
  557. await this.getSalesmanList()
  558. this.getDictList()
  559. this.getTypeList()
  560. this.getDealerList()
  561. if (this.listItem) {
  562. this.getDetail()
  563. } else {
  564. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  565. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  566. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  567. this.mainForm.createDate = this.getDate(0)
  568. this.mainForm.contractDate = this.getDate(1)
  569. }
  570. },
  571. methods: {
  572. // 返回列表
  573. goBack() {
  574. this.$emit('backListFormDetail')
  575. },
  576. getDate(addYear) {
  577. var date = new Date()
  578. var seperator1 = '-'
  579. var year = date.getFullYear() + addYear
  580. var month = date.getMonth() + 1
  581. var strDate = date.getDate()
  582. if (month >= 1 && month <= 9) {
  583. month = '0' + month
  584. }
  585. if (strDate >= 0 && strDate <= 9) {
  586. strDate = '0' + strDate
  587. }
  588. var currentdate = year + seperator1 + month + seperator1 + strDate
  589. return currentdate
  590. },
  591. // 获取详情
  592. getDetail() {
  593. getEnginDetail({ id: this.listItem.enginInfoId }).then(res => {
  594. const data = res.data
  595. this.mainForm.orderNum = data.enginInfoNo
  596. this.mainForm.orderDate = data.orderDate
  597. // this.mainForm.mainId = data.productCategoryId;
  598. this.mainForm.jxsNum = data.customerNumber
  599. this.mainForm.enginName = data.projectName
  600. this.mainForm.machineType = data.machineType
  601. this.mainForm.jxsName = data.customerName
  602. this.mainForm.company = data.useUnit
  603. this.mainForm.tradeCategory = data.tradeCategory
  604. this.mainForm.address = data.installAddress
  605. this.mainForm.enginNum = data.projectNo
  606. this.mainForm.factoryNum = data.enginFactoryNo
  607. this.mainForm.loginType = data.enginSignType
  608. this.mainForm.linkman = data.linkman
  609. this.mainForm.phone = data.phone
  610. this.mainForm.tel = data.tel
  611. this.mainForm.remark = data.remark
  612. this.mainForm.salesMan = data.serviceId
  613. this.mainForm.createMan = data.createName
  614. this.mainForm.createDate = data.createTime
  615. this.mainForm.contractDate = data.contractExpireDate
  616. this.mainForm.power = data.powerCategory
  617. this.mainForm.greeRemark = data.geLiInerNote
  618. this.mainForm.greeReply = data.geLiNote
  619. this.mainForm.fileNo = data.fileNo
  620. this.examineStatus = data.examineStatus
  621. data.items.forEach(item => {
  622. item.cantDel = true
  623. item.cid = item.id
  624. })
  625. this.goodsList = data.items
  626. })
  627. },
  628. // 获取经销商列表
  629. getDealerList() {
  630. getDealerList({
  631. pageNum: 1,
  632. pageSize: -1
  633. // bindUser: false
  634. }).then(res => {
  635. this.dealerList = res.data.records
  636. })
  637. },
  638. // 获取产品大类列表
  639. getDictList() {
  640. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  641. this.typeList = res.data
  642. })
  643. getDictList({ sysDictEnum: 'MACHINE_TYPE' }).then(res => {
  644. this.machineTypeList = res.data
  645. })
  646. getDictList({ sysDictEnum: 'POWER_CATEGORY' }).then(res => {
  647. this.powerList = res.data
  648. })
  649. getDictList({ sysDictEnum: 'SIGN_TYPE' }).then(res => {
  650. this.loginTypeList = res.data
  651. })
  652. },
  653. // 获取销售类型列表
  654. getTypeList() {
  655. getTypeList({
  656. pageNum: 1,
  657. pageSize: -1
  658. }).then(res => {
  659. this.salesTypeList = res.data.records
  660. })
  661. },
  662. async getSalesmanList() {
  663. const res = await getSalesmanList({
  664. pageNum: 1,
  665. pageSize: -1,
  666. isCustomer: 0,
  667. status: true
  668. })
  669. this.salesmanList = res.data.records
  670. },
  671. changeDealer() {
  672. if (this.mainForm.jxsNum) {
  673. const jxsItem = this.dealerList.find(o => o.number == this.mainForm.jxsNum)
  674. this.mainForm.jxsName = jxsItem.name
  675. this.mainForm.jxsId = jxsItem.id
  676. } else {
  677. this.mainForm.jxsName = ''
  678. this.mainForm.jxsId = ''
  679. }
  680. },
  681. changeSaleType(index) {
  682. if (this.goodsList[index].saleTypeId) {
  683. const obj = this.salesTypeList.find(o => o.id == this.goodsList[index].saleTypeId)
  684. this.goodsList[index].saleTypeName = obj.saleName
  685. this.goodsList[index].saleTypeCode = obj.saleCode
  686. } else {
  687. this.goodsList[index].saleTypeName = ''
  688. this.goodsList[index].saleTypeCode = ''
  689. }
  690. },
  691. // 获取商品列表
  692. getGoodsList() {
  693. getRetailProductList({
  694. pageNum: this.currentPage,
  695. pageSize: 10,
  696. saleId: this.goodsScreenForm.salesType,
  697. materialCode: this.goodsScreenForm.proNum,
  698. materialName: this.goodsScreenForm.proName,
  699. specification: this.goodsScreenForm.proModel,
  700. price1: this.goodsScreenForm.price1,
  701. price2: this.goodsScreenForm.price2,
  702. customerId: this.listItem ? this.listItem.customerId : ''
  703. }).then(res => {
  704. const oldGoodsList = this.goodsList
  705. const newGoodsList = res.data.records
  706. for (let i = 0; i < oldGoodsList.length; i++) {
  707. const oldItem = oldGoodsList[i]
  708. for (let j = 0; j < newGoodsList.length; j++) {
  709. const newItem = newGoodsList[j]
  710. if (newItem.id === oldItem.id) {
  711. newGoodsList[j].selected = true
  712. break
  713. }
  714. }
  715. }
  716. res.data.records.forEach(item => {
  717. item.materialName = item.name
  718. item.materialCode = item.number
  719. item.saleTypeName = item.saleName
  720. item.unit = item.baseUnit
  721. item.price = item.batchPrice
  722. item.tax = item.taxRate
  723. item.isDirectTransfer = false
  724. item.directTransferQty = ''
  725. item.status1 = ''
  726. item.status2 = ''
  727. item.rebateAmount = ''
  728. item.rebateRate = ''
  729. item.productPriceId = item.id
  730. // item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  731. })
  732. this.leftGoodsList = res.data.records
  733. this.listTotal = res.data.total
  734. })
  735. },
  736. // 查询重复值并禁选
  737. checkboxSelect(row, rowIndex) {
  738. if (row.selected) {
  739. return false // 禁用
  740. } else {
  741. return true // 不禁用
  742. }
  743. },
  744. // 点击 选择商品
  745. openDialog() {
  746. this.isShowGoodsDialog = true
  747. this.getGoodsList()
  748. },
  749. // 提交筛选表单
  750. submitGoodsScreenForm() {
  751. this.currentPage = 1
  752. this.getGoodsList()
  753. },
  754. // 重置筛选表单
  755. resetGoodsScreenForm() {
  756. this.$refs.goodsScreenForm.resetFields()
  757. this.currentPage = 1
  758. this.getGoodsList()
  759. },
  760. // 更改列表当前页
  761. handleTableCurrentChange(val) {
  762. this.currentPage = val
  763. this.getGoodsList()
  764. },
  765. // 关闭 弹窗
  766. closeDialog() {
  767. this.isShowGoodsDialog = false
  768. },
  769. // 左侧列表选择
  770. leftSelectionChange(val) {
  771. this.leftSelection = val
  772. },
  773. // 右侧列表选择
  774. rightSelectionChange(val) {
  775. this.rightSelection = val
  776. },
  777. // 数组去重
  778. delRepeat(arr1, arr2) {
  779. const allArr = arr1.concat(arr2) // 两个数组对象合并
  780. const newArr = [] // 存放去重后数据的新数组
  781. for (let i = 0; i < allArr.length; i++) {
  782. // 循环allArr数组对象的内容
  783. let flag = true // 建立标记,判断数据是否重复,true为不重复
  784. for (let j = 0; j < newArr.length; j++) {
  785. // 循环新数组的内容
  786. if (allArr[i].id == newArr[j].id) {
  787. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  788. flag = false
  789. }
  790. }
  791. if (flag) {
  792. // 判断是否重复
  793. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  794. }
  795. }
  796. return newArr
  797. },
  798. // 全部添加
  799. addAllGoods() {
  800. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  801. },
  802. // 添加
  803. addGoods() {
  804. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  805. },
  806. // 删除
  807. deleteGoods() {
  808. const rightGoodsList = this.rightGoodsList
  809. const rightSelection = this.rightSelection
  810. for (let i = 0; i < rightGoodsList.length; i++) {
  811. for (let j = 0; j < rightSelection.length; j++) {
  812. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  813. this.rightGoodsList.splice(i, 1)
  814. }
  815. }
  816. }
  817. },
  818. // 全部删除
  819. deleteAllGoods() {
  820. this.rightGoodsList = []
  821. },
  822. // 确定 添加产品
  823. submitAddGoods() {
  824. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  825. this.goodsList = this.goodsList.concat(this.rightGoodsList)
  826. this.goodsList.forEach(k => {
  827. if (!k.qty) {
  828. k.qty = 0
  829. }
  830. if (!k.cid) {
  831. k.cid = ''
  832. }
  833. })
  834. this.isShowGoodsDialog = false
  835. this.leftGoodsList = []
  836. this.rightGoodsList = []
  837. },
  838. // 删除产品
  839. deleteItem(index, row, id) {
  840. // id id存在就说明这个货品已经引用过了
  841. // if (this.listItem && this.examineStatus === 'OK' && id) {
  842. // this.$errorMsg('已审核通过的型号不能删除')
  843. // return
  844. // }
  845. if (id) {
  846. delItem({
  847. enginInfoNo: row.enginInfoNo,
  848. itemId: row.id
  849. }).then(res => {
  850. this.goodsList.splice(index, 1)
  851. this.$successMsg('存在的货品删除成功')
  852. })
  853. } else {
  854. this.goodsList.splice(index, 1)
  855. this.$successMsg('删除成功')
  856. }
  857. },
  858. // 导入产品
  859. getImportList(data) {
  860. this.goodsList = this.goodsList.concat(data)
  861. },
  862. clickSubmitForm(type) {
  863. this.$refs.mainForm.validate(valid => {
  864. if (valid) {
  865. for (let i = 0; i < this.goodsList.length; i++) {
  866. if (!this.goodsList[i].saleTypeId) {
  867. this.$errorMsg('请选择销售类型')
  868. return
  869. }
  870. console.log(this.goodsList[i].qty)
  871. if (this.goodsList[i].qty == null || this.goodsList[i].qty === '' || Number(this.goodsList[i].qty) < 0) {
  872. this.$errorMsg('数量不能为空或者小于0')
  873. return
  874. }
  875. if (!this.goodsList[i].materialNumber) {
  876. return
  877. }
  878. }
  879. const goodsList = JSON.parse(JSON.stringify(this.goodsList))
  880. goodsList.forEach(item => {
  881. delete item.productList
  882. delete item.id
  883. })
  884. const saleManItem = this.mainForm.salesMan
  885. ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan)
  886. : ''
  887. const params = {
  888. // orderDate: this.mainForm.orderDate + ' 00:00:00',
  889. // mainId: this.mainForm.mainId,
  890. projectName: this.mainForm.enginName,
  891. machineType: this.mainForm.machineType,
  892. useUnit: this.mainForm.company,
  893. tradeCategory: this.mainForm.tradeCategory,
  894. installAddress: this.mainForm.address,
  895. projectNo: this.mainForm.enginNum,
  896. enginFactoryNo: this.mainForm.factoryNum,
  897. enginSignType: this.mainForm.loginType,
  898. linkman: this.mainForm.linkman,
  899. phone: this.mainForm.phone,
  900. serviceId: this.mainForm.salesMan,
  901. serviceName: saleManItem.nickName,
  902. tel: this.mainForm.tel,
  903. remark: this.mainForm.remark,
  904. contractExpireDate: this.mainForm.contractDate,
  905. powerCategory: this.mainForm.power,
  906. geLiInerNote: this.mainForm.greeRemark,
  907. geLiNote: this.mainForm.greeReply,
  908. fileNo: this.mainForm.fileNo,
  909. items: goodsList
  910. }
  911. console.log(params)
  912. if (type === 1) {
  913. if (this.listItem) {
  914. params.enginInfoId = this.listItem.enginInfoId
  915. editEngin(params).then(res => {
  916. this.$successMsg('编辑成功')
  917. this.goBack()
  918. })
  919. } else {
  920. params.customerNumber = this.mainForm.jxsNum
  921. params.customerName = this.mainForm.jxsName
  922. params.customerId = this.mainForm.jxsId
  923. addEngin(params).then(res => {
  924. this.$successMsg('保存成功')
  925. this.goBack()
  926. })
  927. }
  928. } else {
  929. if (this.listItem) {
  930. params.enginInfoId = this.listItem.enginInfoId
  931. } else {
  932. params.customerNumber = this.mainForm.jxsNum
  933. params.customerName = this.mainForm.jxsName
  934. params.customerId = this.mainForm.jxsId
  935. }
  936. submitEngin(params).then(res => {
  937. this.$successMsg('提交审核成功')
  938. this.goBack()
  939. })
  940. }
  941. }
  942. })
  943. }
  944. }
  945. }
  946. </script>
  947. <style scoped lang="scss">
  948. .detail-container {
  949. width: 100%;
  950. height: 100%;
  951. }
  952. .main-title {
  953. display: flex;
  954. justify-content: space-between;
  955. align-items: center;
  956. margin-top: 20px;
  957. height: 60px;
  958. border-bottom: 1px solid #dcdfe6;
  959. margin-bottom: 20px;
  960. .title {
  961. font-size: 16px;
  962. font-weight: 600;
  963. padding-left: 10px;
  964. }
  965. }
  966. .tables {
  967. display: flex;
  968. margin-top: 10px;
  969. .table {
  970. width: 45%;
  971. }
  972. .buttons {
  973. display: flex;
  974. flex-direction: column;
  975. justify-content: center;
  976. align-items: center;
  977. padding: 0 10px;
  978. button {
  979. margin: 0;
  980. margin-top: 10px;
  981. }
  982. }
  983. }
  984. ::v-deep input::-webkit-outer-spin-button,
  985. ::v-deep input::-webkit-inner-spin-button {
  986. -webkit-appearance: none;
  987. }
  988. ::v-deep input[type='number'] {
  989. -moz-appearance: textfield;
  990. }
  991. </style>