materiel.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <fullscreen :fullscreen.sync="fullscreen" class="container">
  3. <div class="container-box">
  4. <toolList @iconCli='iconCli' :tooltit='tooltit'></toolList>
  5. <div class="search">
  6. <mySearch :searchList="searchList" @searchInfo="searchInfo"></mySearch>
  7. <el-button class="btn-check" size="medium" type="primary" @click="dialogCheck(3)">添加
  8. </el-button>
  9. </div>
  10. <div class="tabbox">
  11. <el-table height="calc(100% - 40px)" class="com-table" ref="multipleTable" :data="tableData"
  12. tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">
  13. <el-table-column prop="sceneName" label="场景">
  14. </el-table-column>
  15. <el-table-column prop="metirialType" label="细分类型">
  16. </el-table-column>
  17. <el-table-column prop="metirialName" label="物料名称">
  18. </el-table-column>
  19. <el-table-column prop="metirialCode" label="物料编码" show-overflow-tooltip>
  20. </el-table-column>
  21. <el-table-column prop="quality" label="材质" width="200" show-overflow-tooltip>
  22. </el-table-column>
  23. <el-table-column prop="size" label="规格" show-overflow-tooltip>
  24. </el-table-column>
  25. <el-table-column prop="unit" label="单位">
  26. </el-table-column>
  27. <el-table-column prop="price" label="单价">
  28. </el-table-column>
  29. <el-table-column prop="proviceFlagName" label="申请权限">
  30. </el-table-column>
  31. <el-table-column label="操作" width="160px" align="center">
  32. <template slot-scope="scope">
  33. <el-button size="mini" type="primary" @click="dialogCheck(1,scope.row)">查看</el-button>
  34. <el-button size="mini" type="primary" @click="dialogCheck(2,scope.row)">修改</el-button>
  35. <el-button size="mini" type="danger" @click="delLine(scope.row)">删除</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next" background
  40. :total="total">
  41. </el-pagination>
  42. </div>
  43. </div>
  44. <el-dialog :title="titname + '物料类型'" :visible.sync="dialogStatus" width="50%" :destroy-on-close="true"
  45. :modal-append-to-body="false" :close-on-click-modal="false" :before-close="closedia">
  46. <div v-loading="loadinged">
  47. <el-form :model="infolist" ref="infolist" :rules="rules" style="height: 50vh;overflow-y: scroll;">
  48. <div class="info-line">
  49. <el-form-item prop="scene">
  50. <span>使用场景</span>
  51. <el-select :disabled="disableStatus" :popper-append-to-body="false"
  52. v-model="infolist.scene" placeholder="使用场景" @change="usePlance">
  53. <el-option v-for="item in sceneopt" :key="item.dataCode" :label="item.dataName"
  54. :value="item.dataCode">
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item prop="metirialName">
  59. <span>物料名称</span>
  60. <el-select :disabled="disableStatus" :popper-append-to-body="false"
  61. v-model="infolist.metirialName" placeholder="物料名称">
  62. <el-option v-for="item in nameopt" :key="item.dataCode" :label="item.dataName"
  63. :value="item.dataName">
  64. </el-option>
  65. </el-select>
  66. </el-input>
  67. </el-form-item>
  68. <el-form-item prop="metirialType">
  69. <span>细分类型</span>
  70. <el-input v-model="infolist.metirialType" placeholder="细分类型" :disabled="disableStatus">
  71. </el-input>
  72. </el-form-item>
  73. <el-form-item prop="metirialCode">
  74. <span>物料编码</span>
  75. <el-input v-model="infolist.metirialCode" placeholder="物料编码" :disabled="disableStatus">
  76. </el-input>
  77. </el-form-item>
  78. <el-form-item prop="proviceFlag">
  79. <span>申请权限</span>
  80. <el-select :disabled="disableStatus" :popper-append-to-body="false"
  81. v-model="infolist.proviceFlag" placeholder="申请权限">
  82. <el-option v-for="item in proviceopt" :key="item.id" :label="item.name"
  83. :value="item.id">
  84. </el-option>
  85. </el-select>
  86. </el-form-item>
  87. <el-form-item prop="supplierCode">
  88. <span>供应商</span>
  89. <el-select :disabled="disableStatus" :popper-append-to-body="false"
  90. v-model="infolist.supplierCode" placeholder="供应商" @change="verifall">
  91. <el-option v-for="item in suppOpt" :key="item.code" :label="item.name"
  92. :value="item.code">
  93. </el-option>
  94. </el-select>
  95. </el-form-item>
  96. <el-form-item prop="size">
  97. <span>规格尺寸</span>
  98. <el-input v-model="infolist.size" placeholder="规格尺寸" :disabled="disableStatus"></el-input>
  99. </el-form-item>
  100. <el-form-item prop="unit">
  101. <span>单位</span>
  102. <el-input v-model="infolist.unit" placeholder="单位" :disabled="disableStatus"></el-input>
  103. </el-form-item>
  104. <el-form-item prop="price">
  105. <span>单价</span>
  106. <el-input type="number" v-model="infolist.price" placeholder="不含税单价" :disabled="disableStatus"></el-input>
  107. </el-form-item>
  108. <el-form-item>
  109. <span>税率</span>
  110. <el-input v-model="infolist.tax" placeholder="税率" :disabled="disableStatus"></el-input>
  111. </el-form-item>
  112. <el-form-item>
  113. <span>安装</span>
  114. <el-input v-model="infolist.install" placeholder="是否需要安装" :disabled="disableStatus"></el-input>
  115. </el-form-item>
  116. </div>
  117. <el-form-item class="info-line online" prop="quality">
  118. <span>物料材质</span>
  119. <el-input v-model="infolist.quality" placeholder="物料材质" :disabled="disableStatus"
  120. type="textarea" :rows="4"></el-input>
  121. </el-form-item>
  122. </el-form>
  123. <div slot="footer" class="dialog-footer myfooter">
  124. <el-button type="primary" @click="dialogCli(2)" v-if="titname !== '查看'">确 定</el-button>
  125. <el-button @click="dialogCli(1)" v-if="titname === '查看'">确 定</el-button>
  126. <el-button @click="dialogCli(1)">取 消</el-button>
  127. </div>
  128. </div>
  129. </el-dialog>
  130. <myMessage :messTit='messTit' @closeMessage="closeMessage" :centerDialogVisible="centerDialogVisible"
  131. v-if="centerDialogVisible"></myMessage>
  132. </fullscreen>
  133. </template>
  134. <script>
  135. import mySearch from "../../../components/search.vue";
  136. import myMessage from "../../../components/myMessage.vue"
  137. import toolList from '../../../components/toolList'
  138. export default {
  139. components: {
  140. mySearch,
  141. myMessage,
  142. toolList
  143. },
  144. data() {
  145. const scene = (rule, value, callback) => {
  146. if (!this.infolist.scene) {
  147. callback(new Error('不能为空'))
  148. } else {
  149. callback()
  150. }
  151. }
  152. const metirialName = (rule, value, callback) => {
  153. if (!this.infolist.metirialName) {
  154. callback(new Error('不能为空'))
  155. } else {
  156. callback()
  157. }
  158. }
  159. const metirialType = (rule, value, callback) => {
  160. if (!this.infolist.metirialType) {
  161. callback(new Error('不能为空'))
  162. } else {
  163. callback()
  164. }
  165. }
  166. const metirialCode = (rule, value, callback) => {
  167. if (!this.infolist.metirialCode) {
  168. callback(new Error('不能为空'))
  169. } else {
  170. callback()
  171. }
  172. }
  173. const proviceFlag = (rule, value, callback) => {
  174. if (!this.infolist.proviceFlag) {
  175. callback(new Error('不能为空'))
  176. } else {
  177. callback()
  178. }
  179. }
  180. const supplierCode = (rule, value, callback) => {
  181. if (!this.infolist.supplierCode) {
  182. callback(new Error('不能为空'))
  183. } else {
  184. callback()
  185. }
  186. }
  187. const size = (rule, value, callback) => {
  188. if (!this.infolist.size) {
  189. callback(new Error('不能为空'))
  190. } else {
  191. callback()
  192. }
  193. }
  194. const unit = (rule, value, callback) => {
  195. if (!this.infolist.unit) {
  196. callback(new Error('不能为空'))
  197. } else {
  198. callback()
  199. }
  200. }
  201. const price = (rule, value, callback) => {
  202. if (!this.infolist.price) {
  203. callback(new Error('不能为空'))
  204. } else {
  205. callback()
  206. }
  207. }
  208. const quality = (rule, value, callback) => {
  209. if (!this.infolist.quality) {
  210. callback(new Error('不能为空'))
  211. } else {
  212. callback()
  213. }
  214. }
  215. return {
  216. rules: {
  217. scene: [{
  218. required: true,
  219. trigger: 'change',
  220. validator: scene
  221. }],
  222. metirialName: [{
  223. required: true,
  224. trigger: 'change',
  225. validator: metirialName
  226. }],
  227. metirialType: [{
  228. required: true,
  229. trigger: 'blur',
  230. validator: metirialType
  231. }],
  232. metirialCode: [{
  233. required: true,
  234. trigger: 'blur',
  235. validator: metirialCode
  236. }],
  237. proviceFlag: [{
  238. required: true,
  239. trigger: 'change',
  240. validator: proviceFlag
  241. }],
  242. supplierCode: [{
  243. required: true,
  244. trigger: 'change',
  245. validator: supplierCode
  246. }],
  247. size: [{
  248. required: true,
  249. trigger: 'blur',
  250. validator: size
  251. }],
  252. unit: [{
  253. required: true,
  254. trigger: 'blur',
  255. validator: unit
  256. }],
  257. price: [{
  258. required: true,
  259. trigger: 'change',
  260. validator: price
  261. }],
  262. quality: [{
  263. required: true,
  264. trigger: 'change',
  265. validator: quality
  266. }],
  267. },
  268. searchList: [{
  269. type: 'input',
  270. tit: '物料名称',
  271. value: '',
  272. width: '98%',
  273. }, ],
  274. tooltit: '二采物料类型建档',
  275. fullscreen: false,
  276. total: 0,
  277. pageSize: 1,
  278. tableData: [],
  279. dialogStatus: false,
  280. disableStatus: false,
  281. titname: '',
  282. infolist: {},
  283. userInfo: {},
  284. params: {},
  285. centerDialogVisible: false,
  286. messTit: '',
  287. delid: '',
  288. loading: false,
  289. loadinged: false,
  290. //申请权限
  291. proviceopt: [{
  292. id: '0',
  293. name: '省公司'
  294. },
  295. {
  296. id: '1',
  297. name: '地市公司'
  298. },
  299. {
  300. id: '2',
  301. name: '省+地市'
  302. },
  303. ],
  304. //使用场景
  305. sceneopt: [{
  306. dataName: '小区',
  307. dataCode: '1'
  308. }, {
  309. dataName: '校园',
  310. dataCode: '2'
  311. }, {
  312. dataName: '营业厅',
  313. dataCode: '3'
  314. }],
  315. //物料名称
  316. nameopt:[],
  317. //供应商
  318. suppOpt:[],
  319. }
  320. },
  321. methods: {
  322. //处理所需数据
  323. verifall(v) {
  324. for (let j = 0; j < this.suppOpt.length; j++) {
  325. if (this.suppOpt[j].code == v) {
  326. this.infolist.supplierName = this.suppOpt[j].name
  327. }
  328. }
  329. },
  330. usePlance(v){
  331. let value = ''
  332. if(v == '1'){
  333. value = 'house';
  334. }else if(v == '2'){
  335. value = 'school';
  336. }else if(v == '3'){
  337. value = 'serviceHall';
  338. }
  339. this.$http({
  340. url: "/market/cfgDataDict/queryList",
  341. method: "post",
  342. headers: {
  343. "Content-Type": "application/json",
  344. },
  345. data: {
  346. dictCode: value
  347. },
  348. }).then((res) => {
  349. this.nameopt = res.data;
  350. });
  351. },
  352. closedia() {
  353. this.infolist = {};
  354. this.dialogStatus = false;
  355. },
  356. //搜索数据
  357. searchInfo(v) {
  358. this.params = {};
  359. v[0] ? this.params.metirialType = v[0] : '';
  360. this.getList(this.params, this.pageSize);
  361. },
  362. //获取列表
  363. getList(v, n) {
  364. this.pageSize = n;
  365. let _this = this;
  366. this.loading = true;
  367. this.tableData = [];
  368. this.$http({
  369. url: "/market/cadvSecbuyMetirial/queryPage",
  370. method: "post",
  371. headers: {
  372. "Content-Type": "application/json",
  373. "page": '{"pageNo":"' + n + '","pageSize":"10"}'
  374. },
  375. data: v,
  376. }).then((res) => {
  377. res.data.data.forEach(item=>{
  378. for (let i = 0; i < this.sceneopt.length; i++) {
  379. if(this.sceneopt[i].dataCode == item.scene){
  380. item.sceneName = this.sceneopt[i].dataName;
  381. }
  382. }
  383. })
  384. this.tableData = res.data.data;
  385. this.total = res.data.totalRecord;
  386. this.loading = false;
  387. });
  388. },
  389. // 分页
  390. currchange(v) {
  391. this.pageSize = v;
  392. this.getList(this.params, this.pageSize);
  393. },
  394. //申请
  395. dialogCheck(v, n) {
  396. this.dialogStatus = true;
  397. this.infolist = Object.assign({}, n);
  398. if (v === 1) {
  399. this.titname = '查看';
  400. this.disableStatus = true;
  401. return
  402. } else if (v === 2) {
  403. this.titname = '修改';
  404. this.disableStatus = false;
  405. this.usePlance(n.scene);
  406. } else if (v === 3) {
  407. this.titname = '添加';
  408. this.disableStatus = false;
  409. }
  410. this.infolist.opNo = this.userInfo.loginNo;
  411. this.infolist.opName = this.userInfo.loginName;
  412. },
  413. //添加
  414. dialogCli(v) {
  415. if (v === 1) {
  416. this.infolist = {};
  417. this.dialogStatus = false;
  418. return
  419. } else {
  420. this.infolist.opTime = this.$formatDate(new Date(), "YYYY-MM-DD");
  421. this.infolist.sts = "0";
  422. this.infolist.stsDesc = "在用";
  423. this.infolist.proviceFlagName = this.infolist.proviceFlag == "0"?'省公司':'地市公司';
  424. if (this.titname === '添加') {
  425. this.submitInfo("/market/cadvSecbuyMetirial/add");
  426. } else if (this.titname === '修改') {
  427. this.submitInfo("/market/cadvSecbuyMetirial/update", v);
  428. }
  429. }
  430. },
  431. submitInfo(u) {
  432. let _this = this;
  433. this.$refs.infolist.validate(valid => {
  434. if (valid) {
  435. this.loadinged = true;
  436. this.$http({
  437. url: u,
  438. method: "post",
  439. headers: {
  440. "Content-Type": "application/json",
  441. },
  442. data: this.infolist,
  443. }).then((res) => {
  444. this.loadinged = false;
  445. if (res.data.result === 1) {
  446. _this.$message({
  447. message: res.data.desc,
  448. type: 'error'
  449. });
  450. } else {
  451. _this.$message({
  452. message: '成功',
  453. type: 'success'
  454. });
  455. _this.infolist = {};
  456. _this.dialogStatus = false;
  457. _this.getList({}, _this.pageSize);
  458. }
  459. });
  460. }
  461. })
  462. },
  463. closeMessage(v) {
  464. this.centerDialogVisible = false;
  465. let _this = this;
  466. if (v === 1) {
  467. _this.$http({
  468. url: "/market/cadvSecbuyMetirial/del",
  469. method: "post",
  470. headers: {
  471. "Content-Type": "application/json",
  472. },
  473. data: {
  474. id: this.delid
  475. },
  476. }).then((res) => {
  477. if (res.data.result === 1) {
  478. _this.$message({
  479. message: res.data.desc,
  480. type: 'error'
  481. });
  482. } else {
  483. _this.$message({
  484. message: '删除成功',
  485. type: 'success'
  486. });
  487. _this.getList(this.params, this.pageSize);
  488. }
  489. });
  490. }
  491. },
  492. //删除
  493. delLine(v) {
  494. this.centerDialogVisible = true;
  495. this.messTit = '即将删除此条数据, 是否删除?';
  496. this.delid = v.id;
  497. },
  498. //文件返回值
  499. uploadBack(v) {
  500. console.log(v)
  501. },
  502. //功能栏
  503. iconCli(v) {
  504. if (v === 1) {
  505. this.getList(this.params, this.pageSize);
  506. }
  507. if (v === 2) {
  508. this.fullscreen = !this.fullscreen
  509. }
  510. },
  511. getUser() {
  512. this.userInfo = JSON.parse(window.sessionStorage.userInfo);
  513. this.$http({
  514. url: "/market/cadvSupplier/queryValidSupplierList",
  515. method: "post",
  516. headers: {
  517. "Content-Type": "application/json",
  518. },
  519. data: {"buyTypeCode":"2"},
  520. }).then((res) => {
  521. this.suppOpt = res.data;
  522. });
  523. }
  524. },
  525. mounted() {
  526. this.getList({}, 1);
  527. this.getUser();
  528. },
  529. created() {
  530. }
  531. }
  532. </script>
  533. <style scoped lang="scss">
  534. .onetab {
  535. margin-bottom: 20px;
  536. padding: 0 20px;
  537. }
  538. .titbox {
  539. div {
  540. float: right;
  541. i {
  542. font-size: 22px;
  543. margin-left: 20px;
  544. cursor: pointer;
  545. }
  546. }
  547. }
  548. .tabbox {
  549. margin-top: 15px;
  550. }
  551. .pageBox {
  552. text-align: right;
  553. margin-top: 10px;
  554. }
  555. .info-line {
  556. width: 100%;
  557. display: block;
  558. padding-left: 20px;
  559. div {
  560. width: 50%;
  561. display: inline-block;
  562. }
  563. span {
  564. width: 80px;
  565. display: inline-block;
  566. text-align: left;
  567. i {
  568. color: red;
  569. display: inline-block;
  570. padding-right: 5px;
  571. }
  572. }
  573. .el-select,
  574. .el-input {
  575. width: calc(100% - 100px);
  576. }
  577. }
  578. .online {
  579. width: 100%;
  580. .el-select {
  581. width: calc(100% - 100px);
  582. }
  583. span {
  584. vertical-align: top;
  585. }
  586. .el-textarea {
  587. width: calc(100% - 100px);
  588. }
  589. }
  590. </style>