engin_form.vue 36 KB

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