engin_form.vue 34 KB

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